Development

Changeset 4961

You must first sign up to be able to contribute.

Changeset 4961

Show
Ignore:
Timestamp:
09/03/07 11:41:03 (1 year ago)
Author:
fabien
Message:

added a new auto_shutdown options for classes that have a shutdown() method

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/config/sfFactoryConfigHandler.class.php

    r4957 r4961  
    113113        case 'storage': 
    114114          $defaultParameters = array(); 
    115           $defaultParameters[] = sprintf("'session_id' => \$this->getRequest()->getParameter('%s'),", $parameters['session_name']); 
     115          $defaultParameters[] = sprintf("'auto_shutdown' => false, 'session_id' => \$this->getRequest()->getParameter('%s'),", $parameters['session_name']); 
    116116          if (is_subclass_of($class, 'sfDatabaseSessionStorage')) 
    117117          { 
     
    123123 
    124124        case 'user': 
    125           $instances[] = sprintf("  \$class = sfConfig::get('sf_factory_user', '%s');\n  \$this->factories['user'] = new \$class(\$this->dispatcher, \$this->factories['storage'], array_merge(array('culture' => \$this->factories['request']->getParameter('sf_culture'), 'default_culture' => sfConfig::get('sf_i18n_default_culture'), 'use_flash' => sfConfig::get('sf_use_flash')), sfConfig::get('sf_factory_user_parameters', %s)));", $class, var_export(is_array($parameters) ? $parameters : array(), true)); 
     125          $instances[] = sprintf("  \$class = sfConfig::get('sf_factory_user', '%s');\n  \$this->factories['user'] = new \$class(\$this->dispatcher, \$this->factories['storage'], array_merge(array('auto_shutdown' => false, 'culture' => \$this->factories['request']->getParameter('sf_culture'), 'default_culture' => sfConfig::get('sf_i18n_default_culture'), 'use_flash' => sfConfig::get('sf_use_flash')), sfConfig::get('sf_factory_user_parameters', %s)));", $class, var_export(is_array($parameters) ? $parameters : array(), true)); 
    126126          break; 
    127127 
     
    159159 
    160160        case 'routing': 
    161           $instances[] = sprintf("  \$class = sfConfig::get('sf_factory_routing', '%s');\n  \$this->factories['routing'] = new \$class(\$this->dispatcher, array_merge(array('suffix' => sfConfig::get('sf_suffix'), 'default_module' => sfConfig::get('sf_default_module'), 'default_action' => sfConfig::get('sf_default_action')), sfConfig::get('sf_factory_routing_parameters', %s)));", $class, var_export(is_array($parameters) ? $parameters : array(), true)); 
     161          $instances[] = sprintf("  \$class = sfConfig::get('sf_factory_routing', '%s');\n  \$this->factories['routing'] = new \$class(\$this->dispatcher, array_merge(array('auto_shutdown' => false, 'suffix' => sfConfig::get('sf_suffix'), 'default_module' => sfConfig::get('sf_default_module'), 'default_action' => sfConfig::get('sf_default_action')), sfConfig::get('sf_factory_routing_parameters', %s)));", $class, var_export(is_array($parameters) ? $parameters : array(), true)); 
    162162          if (isset($parameters['load_configuration']) && $parameters['load_configuration']) 
    163163          { 
     
    193193              { 
    194194                // create logger instance 
    195                 $loggers .= sprintf("\n\$logger = new %s(\$this->dispatcher, %s);\n\$this->factories['logger']->addLogger(\$logger);\n",  
     195                $loggers .= sprintf("\n\$logger = new %s(\$this->dispatcher, array_merge(array('auto_shutdown' => false), %s));\n\$this->factories['logger']->addLogger(\$logger);\n",  
    196196                              $keys['class'], 
    197                               isset($keys['param']) ? var_export($keys['param'], true) : '
     197                              isset($keys['param']) ? var_export($keys['param'], true) : 'array()
    198198                            ); 
    199199              } 
     
    204204 
    205205          $instances[] = sprintf( 
    206                          "  \$class = sfConfig::get('sf_factory_logger', '%s');\n  \$this->factories['logger'] = new \$class(\$this->dispatcher, sfConfig::get('sf_factory_logger_parameters', %s));\n". 
     206                         "  \$class = sfConfig::get('sf_factory_logger', '%s');\n  \$this->factories['logger'] = new \$class(\$this->dispatcher, array_merge(array('auto_shutdown' => false), sfConfig::get('sf_factory_logger_parameters', %s)));\n". 
    207207                         "  %s" 
    208                          , $class, var_export($parameters, true), $loggers); 
     208                         , $class, var_export(is_array($parameters) ? $parameters : array(), true), $loggers); 
    209209          break; 
    210210      } 
  • trunk/lib/database/sfDatabaseManager.class.php

    r4957 r4961  
    3131   * @see initialize() 
    3232   */ 
    33   public function __construct(
     33  public function __construct($options = array()
    3434  { 
    3535    $this->initialize(); 
     36 
     37    if (isset($options['auto_shutdown']) && $options['auto_shutdown']) 
     38    { 
     39      register_shutdown_function(array($this, 'shutdown')); 
     40    } 
    3641  } 
    3742 
  • trunk/lib/log/sfLogger.class.php

    r4957 r4961  
    4949  { 
    5050    $this->initialize($dispatcher, $options); 
     51 
     52    if (isset($options['auto_shutdown']) && $options['auto_shutdown']) 
     53    { 
     54      register_shutdown_function(array($this, 'shutdown')); 
     55    } 
    5156  } 
    5257 
  • trunk/lib/routing/sfRouting.class.php

    r4957 r4961  
    3232  { 
    3333    $this->initialize($dispatcher, $parameters); 
     34 
     35    if ($this->parameterHolder->get('auto_shutdown', true)) 
     36    { 
     37      register_shutdown_function(array($this, 'shutdown')); 
     38    } 
    3439  } 
    3540 
  • trunk/lib/storage/sfStorage.class.php

    r4957 r4961  
    3232  { 
    3333    $this->initialize($parameters); 
     34 
     35    if ($this->getParameter('auto_shutdown', true)) 
     36    { 
     37      register_shutdown_function(array($this, 'shutdown')); 
     38    } 
    3439  } 
    3540 
  • trunk/lib/user/sfUser.class.php

    r4957 r4961  
    4747  { 
    4848    $this->initialize($dispatcher, $storage, $parameters); 
     49 
     50    if ($this->getParameter('auto_shutdown', true)) 
     51    { 
     52      register_shutdown_function(array($this, 'shutdown')); 
     53    } 
    4954  } 
    5055 
     
    229234 
    230235  /** 
    231    * Execute the shutdown procedure. 
     236   * Executes the shutdown procedure. 
    232237   * 
    233238   * @return void 
  • trunk/lib/util/sfContext.class.php

    r4957 r4961  
    4141    { 
    4242      // setup our database connections 
    43       $this->factories['databaseManager'] = new sfDatabaseManager(); 
     43      $this->factories['databaseManager'] = new sfDatabaseManager(array('auto_shutdown' => false)); 
    4444    } 
    4545 
     
    374374    } 
    375375 
    376     if (sfConfig::get('sf_cache')) 
    377     { 
    378       $this->getViewCacheManager()->shutdown(); 
    379     } 
    380  
    381376    if (sfConfig::get('sf_logging_enabled')) 
    382377    { 
  • trunk/lib/view/sfViewCacheManager.class.php

    r4957 r4961  
    650650    return true; 
    651651  } 
    652  
    653   /** 
    654    * Executes the shutdown procedure. 
    655    */ 
    656   public function shutdown() 
    657   { 
    658   } 
    659652}