sfContext::initialize PHP Method

initialize() public method

Initializes the current sfContext instance.
public initialize ( sfApplicationConfiguration $configuration )
$configuration sfApplicationConfiguration An sfApplicationConfiguration instance
    public function initialize(sfApplicationConfiguration $configuration)
    {
        $this->configuration = $configuration;
        $this->dispatcher = $configuration->getEventDispatcher();
        try {
            $this->loadFactories();
        } catch (sfException $e) {
            $e->printStackTrace();
        } catch (Exception $e) {
            sfException::createFromException($e)->printStackTrace();
        }
        $this->dispatcher->connect('template.filter_parameters', array($this, 'filterTemplateParameters'));
        $this->dispatcher->connect('response.fastcgi_finish_request', array($this, 'shutdownUserAndStorage'));
        // register our shutdown function
        register_shutdown_function(array($this, 'shutdown'));
    }

Usage Example

コード例 #1
0
ファイル: dmContext.php プロジェクト: rafix/diem
 /**
  * Initializes the current dmContext instance.
  *
  * @param dmApplicationConfiguration $configuration  An dmApplicationConfiguration instance
  */
 public function initialize(sfApplicationConfiguration $configuration)
 {
     $this->checkProjectIsSetup();
     parent::initialize($configuration);
     sfConfig::set('dm_debug', $this->getRequest()->getParameter('dm_debug', false));
     // load the service container instance
     $this->loadServiceContainer();
     // configure the service container with its required dependencies
     $this->configureServiceContainer($this->serviceContainer);
     if (method_exists($this->configuration, 'configureServiceContainer')) {
         $this->configuration->configureServiceContainer($this->serviceContainer);
     }
     // connect the service container and its services to the event dispatcher
     $this->serviceContainer->connect();
     /*
      * dmForm requires service container...
      */
     dmForm::setServiceContainer($this->serviceContainer);
     /*
      * some classes needs the event dispatcher to communicate
      * and the service container...
      */
     dmDoctrineQuery::setModuleManager($this->getModuleManager());
     dmDoctrineTable::setServiceContainer($this->serviceContainer);
     $this->helper = $this->serviceContainer->getService('helper');
     // notify that context is ready
     $this->dispatcher->notify(new sfEvent($this, 'dm.context.loaded'));
 }
All Usage Examples Of sfContext::initialize