Development

Changeset 4957

You must first sign up to be able to contribute.

Changeset 4957

Show
Ignore:
Timestamp:
09/03/07 10:58:56 (1 year ago)
Author:
fabien
Message:

* refactored objects creation and initialization

  • removed newInstance() methods
  • construct() now calls initialize()
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/data/skeleton/batch/default.php

    r1686 r4957  
    2020// initialize database manager 
    2121//$databaseManager = new sfDatabaseManager(); 
    22 //$databaseManager->initialize(); 
    2322 
    2423// batch process here 
  • trunk/lib/action/sfAction.class.php

    r4951 r4957  
    3131   * @return bool true, if initialization completes successfully, otherwise false 
    3232   */ 
    33   public function initialize($context
    34   { 
    35     parent::initialize($context); 
     33  public function initialize($context, $moduleName, $actionName
     34  { 
     35    parent::initialize($context, $moduleName, $actionName); 
    3636 
    3737    // include security configuration 
    3838    require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$this->getModuleName().'/'.sfConfig::get('sf_app_module_config_dir_name').'/security.yml', true)); 
    39  
    40     return true; 
    4139  } 
    4240 
  • trunk/lib/action/sfComponent.class.php

    r4951 r4957  
    2020{ 
    2121  protected 
     22    $moduleName             = '', 
     23    $actionName             = '', 
    2224    $context                = null, 
    2325    $dispatcher             = null, 
     
    2830 
    2931  /** 
     32   * Class constructor. 
     33   * 
     34   * @see initialize() 
     35   */ 
     36  public function __construct($context, $moduleName, $actionName) 
     37  { 
     38    $this->initialize($context, $moduleName, $actionName); 
     39  } 
     40 
     41  /** 
    3042   * Initializes this component. 
    3143   * 
     
    3446   * @return boolean true, if initialization completes successfully, otherwise false 
    3547   */ 
    36   public function initialize($context) 
    37   { 
     48  public function initialize($context, $moduleName, $actionName) 
     49  { 
     50    $this->moduleName             = $moduleName; 
     51    $this->actionName             = $actionName; 
    3852    $this->context                = $context; 
    3953    $this->dispatcher             = $context->getEventDispatcher(); 
     
    4256    $this->response               = $context->getResponse(); 
    4357    $this->requestParameterHolder = $this->request->getParameterHolder(); 
    44  
    45     return true; 
    4658  } 
    4759 
     
    6880  public function getModuleName() 
    6981  { 
    70     return $this->context->getModuleName()
     82    return $this->moduleName
    7183  } 
    7284 
     
    7890  public function getActionName() 
    7991  { 
    80     return $this->context->getActionName()
     92    return $this->actionName
    8193  } 
    8294 
  • trunk/lib/cache/sfCache.class.php

    r4586 r4957  
    2727 
    2828  /** 
    29    * Retrieves a new sfCache implementation instance. 
    30    * 
    31    * @param  string  A sfCache class name 
    32    * 
    33    * @return sfCache A sfCache implementation instance 
    34    * 
    35    * @throws <b>sfFactoryException</b> If a cache implementation instance cannot be created 
    36    */ 
    37   public static function newInstance($class) 
    38   { 
    39     $object = new $class(); 
    40  
    41     if (!$object instanceof sfCache) 
    42     { 
    43       throw new sfFactoryException(sprintf('Class "%s" is not of the type sfCache.', $class)); 
    44     } 
    45  
    46     return $object; 
     29   * Class constructor. 
     30   * 
     31   * @see initialize() 
     32   */ 
     33  public function __construct($parameters = array()) 
     34  { 
     35    $this->initialize($parameters); 
    4736  } 
    4837 
  • trunk/lib/command/sfSymfonyCommandApplication.class.php

    r4951 r4957  
    8585  protected function initializeLogger() 
    8686  { 
    87     $logger = new sfCommandLogger(); 
    88     $logger->initialize(new sfEventDispatcher(), array('output' => new sfConsoleColorizer())); 
     87    $logger = new sfCommandLogger(new sfEventDispatcher(), array('output' => new sfConsoleColorizer())); 
    8988    $this->setLogger($logger); 
    9089  } 
  • trunk/lib/config/sfConfigCache.class.php

    r4853 r4957  
    271271    // manually create our config_handlers.yml handler 
    272272    $this->handlers['config_handlers.yml'] = new sfRootConfigHandler(); 
    273     $this->handlers['config_handlers.yml']->initialize(); 
    274273 
    275274    // application configuration handlers 
     
    354353  public function registerConfigHandler($handler, $class, $params = array()) 
    355354  { 
    356     $this->userHandlers[$handler] = new $class(); 
    357     $this->userHandlers[$handler]->initialize($params); 
     355    $this->userHandlers[$handler] = new $class($params); 
    358356  } 
    359357 
  • trunk/lib/config/sfConfigHandler.class.php

    r3203 r4957  
    2727 
    2828  /** 
    29    * Executes this configuration handler 
     29   * Class constructor. 
    3030   * 
    31    * @param array An array of filesystem path to a configuration file 
    32    * 
    33    * @return string Data to be written to a cache file 
    34    * 
    35    * @throws <b>sfConfigurationException</b> If a requested configuration file does not exist or is not readable 
    36    * @throws <b>sfParseException</b> If a requested configuration file is improperly formatted 
     31   * @see initialize() 
    3732   */ 
    38   abstract public function execute($configFiles); 
     33  public function __construct($parameters = null) 
     34  { 
     35    $this->initialize($parameters); 
     36  } 
    3937 
    4038  /** 
     
    5250    $this->parameterHolder->add($parameters); 
    5351  } 
     52 
     53  /** 
     54   * Executes this configuration handler 
     55   * 
     56   * @param array An array of filesystem path to a configuration file 
     57   * 
     58   * @return string Data to be written to a cache file 
     59   * 
     60   * @throws <b>sfConfigurationException</b> If a requested configuration file does not exist or is not readable 
     61   * @throws <b>sfParseException</b> If a requested configuration file is improperly formatted 
     62   */ 
     63  abstract public function execute($configFiles); 
    5464 
    5565  /** 
  • trunk/lib/config/sfFactoryConfigHandler.class.php

    r4951 r4957  
    4545    // init our data and includes arrays 
    4646    $includes  = array(); 
    47     $inits     = array(); 
    4847    $instances = array(); 
    4948 
     
    9998      { 
    10099        case 'controller': 
    101           // append instance creation 
    102           $instances[] = sprintf("  \$this->factories['controller'] = sfController::newInstance(sfConfig::get('sf_factory_controller', '%s'));", $class); 
    103  
    104           // append instance initialization 
    105           $inits[] = "  \$this->factories['controller']->initialize(\$this);"; 
     100          $instances[] = sprintf("  \$class = sfConfig::get('sf_factory_controller', '%s');\n   \$this->factories['controller'] = new \$class(\$this);", $class); 
    106101          break; 
    107102 
    108103        case 'request': 
    109           // append instance creation 
    110           $instances[] = sprintf("  \$this->factories['request'] = sfRequest::newInstance(sfConfig::get('sf_factory_request', '%s'));", $class); 
    111  
    112           // append instance initialization 
    113           $inits[] = sprintf("  \$this->factories['request']->initialize(\$this->dispatcher, sfConfig::get('sf_factory_request_parameters', %s), sfConfig::get('sf_factory_request_attributes', array()));", var_export($parameters, true)); 
     104          $instances[] = sprintf("  \$class = sfConfig::get('sf_factory_request', '%s');\n   \$this->factories['request'] = new \$class(\$this->dispatcher, sfConfig::get('sf_factory_request_parameters', %s), sfConfig::get('sf_factory_request_attributes', array()));", $class, var_export($parameters, true)); 
    114105          break; 
    115106 
    116107        case 'response': 
    117           // append instance creation 
    118           $instances[] = sprintf("  \$this->factories['response'] = sfResponse::newInstance(sfConfig::get('sf_factory_response', '%s'));", $class); 
    119  
    120           // append instance initialization 
    121           $inits[] = sprintf("  \$this->factories['response']->initialize(\$this->dispatcher, sfConfig::get('sf_factory_response_parameters', %s));", var_export($parameters, true)); 
    122           $inits[] = sprintf("  if ('HEAD' == \$this->factories['request']->getMethodName())\n  {  \n    \$this->factories['response']->setHeaderOnly(true);\n  }\n"); 
     108          $instances[] = sprintf("  \$class = sfConfig::get('sf_factory_response', '%s');\n  \$this->factories['response'] = new \$class(\$this->dispatcher, sfConfig::get('sf_factory_response_parameters', %s));", $class, var_export($parameters, true)); 
     109 
     110          $instances[] = sprintf("  if ('HEAD' == \$this->factories['request']->getMethodName())\n  {  \n    \$this->factories['response']->setHeaderOnly(true);\n  }\n"); 
    123111          break; 
    124112 
    125113        case 'storage': 
    126           // append instance creation 
    127           $instances[] = sprintf("  \$this->factories['storage'] = sfStorage::newInstance(sfConfig::get('sf_factory_storage', '%s'));", $class); 
    128  
    129           // append instance initialization 
    130114          $defaultParameters = array(); 
    131115          $defaultParameters[] = sprintf("'session_id' => \$this->getRequest()->getParameter('%s'),", $parameters['session_name']); 
     
    134118            $defaultParameters[] = sprintf("'database' => \$this->getDatabaseManager()->getDatabase('%s'),", isset($parameters['database']) ? $parameters['database'] : 'default'); 
    135119          } 
    136           $inits[] = sprintf("  \$this->factories['storage']->initialize(array_merge(array(\n%s\n), sfConfig::get('sf_factory_storage_parameters', %s)));", implode("\n", $defaultParameters), var_export($parameters, true)); 
     120 
     121          $instances[] = sprintf("  \$class = sfConfig::get('sf_factory_storage', '%s');\n  \$this->factories['storage'] = new \$class(array_merge(array(\n%s\n), sfConfig::get('sf_factory_storage_parameters', %s)));", $class, implode("\n", $defaultParameters), var_export($parameters, true)); 
    137122          break; 
    138123 
    139124        case 'user': 
    140           // append instance creation 
    141           $instances[] = sprintf("  \$this->factories['user'] = sfUser::newInstance(sfConfig::get('sf_factory_user', '%s'));", $class); 
    142  
    143           // append instance initialization 
    144           $inits[] = sprintf("  \$this->factories['user']->initialize(\$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)));", 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('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)); 
    145126          break; 
    146127 
    147128        case 'view_cache': 
    148           // append view cache class name 
    149           $inits[] = sprintf("\n  if (sfConfig::get('sf_cache'))\n  {\n". 
    150                              "    \$this->factories['viewCacheManager'] = new sfViewCacheManager();\n". 
    151                              "    \$cache = sfCache::newInstance(sfConfig::get('sf_factory_view_cache', '%s'));\n". 
    152                              "    \$cache->initialize(sfConfig::get('sf_factory_view_cache_parameters', %s));\n". 
    153                              "    \$this->factories['viewCacheManager']->initialize(\$this, \$cache);\n". 
     129          $instances[] = sprintf("\n  if (sfConfig::get('sf_cache'))\n  {\n". 
     130                             "    \$class = sfConfig::get('sf_factory_view_cache', '%s');\n". 
     131                             "    \$cache = new \$class(sfConfig::get('sf_factory_view_cache_parameters', %s));\n". 
     132                             "    \$this->factories['viewCacheManager'] = new sfViewCacheManager(\$this, \$cache);\n". 
    154133                             "  }\n". 
    155134                             "  else\n". 
     
    161140 
    162141        case 'i18n': 
    163           // append i18n instance initialization 
    164142          if (isset($parameters['cache'])) 
    165143          { 
    166             $cache = sprintf("    \$cache = sfCache::newInstance('%s');\n    \$cache->initialize(%s);\n", $parameters['cache']['class'], var_export($parameters['cache']['param'], true)); 
     144            $cache = sprintf("    \$cache = new %s(%s);\n", $parameters['cache']['class'], var_export($parameters['cache']['param'], true)); 
    167145            unset($parameters['cache']); 
    168146          } 
     
    171149            $cache = "    \$cache = null;\n"; 
    172150          } 
    173           $inits[] = sprintf("\n  if (sfConfig::get('sf_i18n'))\n  {\n". 
     151          $instances[] = sprintf("\n  if (sfConfig::get('sf_i18n'))\n  {\n". 
    174152                     "    \$class = sfConfig::get('sf_factory_i18n', '%s');\n". 
    175                      "    \$this->factories['i18n'] = new \$class();\n". 
    176153                     "%s". 
    177                      "    \$this->factories['i18n']->initialize(\$this, \$cache);\n". 
     154                     "    \$this->factories['i18n'] = new \$class(\$this, \$cache);\n". 
    178155                     "  }\n" 
    179156                     , $class, $cache 
     
    182159 
    183160        case 'routing': 
    184           // append instance creation 
    185           $instances[] = sprintf("  \$this->factories['routing'] = sfRouting::newInstance(sfConfig::get('sf_factory_routing', '%s'));", $class); 
    186  
    187           // append instance initialization 
    188           $inits[] = sprintf("  \$this->factories['routing']->initialize(\$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)));", 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('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)); 
     162          if (isset($parameters['load_configuration']) && $parameters['load_configuration']) 
     163          { 
     164            $instances[] = "  \$this->factories['routing']->loadConfiguration();\n"; 
     165          } 
    189166          break; 
    190167 
    191168        case 'logger': 
    192           // append instance creation and initialization 
    193169          $loggers = ''; 
    194170          if (isset($parameters['loggers'])) 
     
    217193              { 
    218194                // create logger instance 
    219                 $loggers .= sprintf("\n\$logger = sfLogger::newInstance('%s');\n\$logger->initialize(\$this->dispatcher, %s);\n\$this->factories['logger']->addLogger(\$logger);\n",  
     195                $loggers .= sprintf("\n\$logger = new %s(\$this->dispatcher, %s);\n\$this->factories['logger']->addLogger(\$logger);\n",  
    220196                              $keys['class'], 
    221197                              isset($keys['param']) ? var_export($keys['param'], true) : '' 
     
    228204 
    229205          $instances[] = sprintf( 
    230                          "  \$this->factories['logger'] = sfLogger::newInstance(sfConfig::get('sf_factory_logger', '%s'));\n". 
    231                          "  \$this->factories['logger']->initialize(\$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, sfConfig::get('sf_factory_logger_parameters', %s));\n". 
    232207                         "  %s" 
    233208                         , $class, var_export($parameters, true), $loggers); 
     
    239214    $retval = sprintf("<?php\n". 
    240215                      "// auto-generated by sfFactoryConfigHandler\n". 
    241                       "// date: %s\n%s\n%s\n%s\n", 
     216                      "// date: %s\n%s\n%s\n", 
    242217                      date('Y/m/d H:i:s'), implode("\n", $includes), 
    243                       implode("\n", $instances), implode("\n", $inits)); 
     218                      implode("\n", $instances)); 
    244219 
    245220    return $retval; 
  • trunk/lib/config/sfFilterConfigHandler.class.php

    r4597 r4957  
    164164  { 
    165165    return sprintf("\nlist(\$class, \$parameters) = (array) sfConfig::get('sf_%s_filter', array('%s', %s));\n". 
    166                       "\$filter = new \$class();\n". 
    167                       "\$filter->initialize(\$this->context, \$parameters);\n". 
     166                      "\$filter = new \$class(\$this->context, \$parameters);\n". 
    168167                      "\$filterChain->register(\$filter);", 
    169168                      $category, $class, $parameters); 
     
    186185if (\$actionInstance->isSecure()) 
    187186{ 
    188   if (!in_array('sfSecurityUser', class_implements(\$this->context->getUser()))) 
    189   { 
    190     throw new sfSecurityException('Security is enabled, but your "sfUser" implementation does not implement "sfSecurityUser" interface.'); 
    191   } 
    192187  {$this->addFilter($category, $class, $parameters)} 
    193188} 
  • trunk/lib/config/sfValidatorConfigHandler.class.php

    r4597 r4957  
    178178          $validator =& $validators[$valName]; 
    179179 
    180           $data[] = sprintf("  \$validators['%s'] = new %s();\n". 
    181                             "  \$validators['%s']->initialize(\$this->context, %s);", 
    182                             $valName, $validator['class'], $valName, $validator['parameters']); 
     180          $data[] = sprintf("  \$validators['%s'] = new %s(\$this->context, %s);\n", 
     181                            $valName, $validator['class'], $validator['parameters']); 
    183182 
    184183          // mark this validator as created for this request method 
  • trunk/lib/controller/sfController.class.php

    r4951 r4957  
    2929 
    3030  /** 
     31   * Class constructor. 
     32   * 
     33   * @see initialize() 
     34   */ 
     35  public function __construct($context) 
     36  { 
     37    $this->initialize($context); 
     38  } 
     39 
     40  /** 
     41   * Initializes this controller. 
     42   * 
     43   * @param sfContext A sfContext implementation instance 
     44   */ 
     45  public function initialize($context) 
     46  { 
     47    $this->context    = $context; 
     48    $this->dispatcher = $context->getEventDispatcher(); 
     49 
     50    if (sfConfig::get('sf_logging_enabled')) 
     51    { 
     52      $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Initialization'))); 
     53    } 
     54 
     55    // set max forwards 
     56    $this->maxForwards = sfConfig::get('sf_max_forwards'); 
     57  } 
     58 
     59  /** 
    3160   * Indicates whether or not a module has a specific component. 
    3261   * 
     
    206235    } 
    207236 
     237    // module enabled? 
    208238    if (sfConfig::get('mod_'.strtolower($moduleName).'_enabled')) 
    209239    { 
    210       // module is enabled 
    211  
    212240      // check for a module config.php 
    213241      $moduleConfig = sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/config.php'; 
     
    217245      } 
    218246 
    219       // initialize the action 
    220       if ($actionInstance->initialize($this->context)) 
    221       { 
    222         // create a new filter chain 
    223         $filterChain = new sfFilterChain(); 
    224  
    225         require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/filters.yml')); 
    226  
    227         $this->context->getEventDispatcher()->notify(new sfEvent($this, 'controller.change_action', array('module' => $moduleName, 'action' => $actionName))); 
    228  
    229         // process the filter chain 
    230         $filterChain->execute(); 
    231       } 
    232       else 
    233       { 
    234         // action failed to initialize 
    235         throw new sfInitializationException(sprintf('Action initialization failed for module "%s", action "%s".', $moduleName, $actionName)); 
    236       } 
     247      // create a new filter chain 
     248      $filterChain = new sfFilterChain(); 
     249 
     250      require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/filters.yml')); 
     251 
     252      $this->context->getEventDispatcher()->notify(new sfEvent($this, 'controller.change_action', array('module' => $moduleName, 'action' => $actionName))); 
     253 
     254      // process the filter chain 
     255      $filterChain->execute(); 
    237256    } 
    238257    else 
    239258    { 
    240       // module is disabled 
    241259      $moduleName = sfConfig::get('sf_module_disabled_module'); 
    242260      $actionName = sfConfig::get('sf_module_disabled_action'); 
     
    307325    } 
    308326 
    309     return new $class(); 
     327    return new $class($this->context, $moduleName, $controllerName); 
    310328  } 
    311329 
     
    363381    { 
    364382      // view class (as configured in module.yml or defined in action) 
    365       $viewName = $this->context->getRequest()->getAttribute($moduleName.'_'.$actionName.'_view_name', sfConfig::get('mod_'.strtolower($moduleName).'_view_class'), 'symfony/action/view'); 
    366       $class    = sfAutoload::getClassPath($viewName.'View') ? $viewName.'View' : 'sfPHPView'; 
    367     } 
    368  
    369     return new $class(); 
    370   } 
    371  
    372   /** 
    373    * Initializes this controller. 
    374    * 
    375    * @param sfContext A sfContext implementation instance 
    376    */ 
    377   public function initialize($context) 
    378   { 
    379     $this->context    = $context; 
    380     $this->dispatcher = $context->getEventDispatcher(); 
    381  
    382     if (sfConfig::get('sf_logging_enabled')) 
    383     { 
    384       $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Initialization'))); 
    385     } 
    386  
    387     // set max forwards 
    388     $this->maxForwards = sfConfig::get('sf_max_forwards'); 
    389   } 
    390  
    391   /** 
    392    * Retrieves a new sfController implementation instance. 
    393    * 
    394    * @param string A sfController class name 
    395    * 
    396    * @return sfController A sfController implementation instance 
    397    * 
    398    * @throws sfFactoryException If a new controller implementation instance cannot be created 
    399    */ 
    400   public static function newInstance($class) 
    401   { 
    402     try 
    403     { 
    404       $object = new $class(); 
    405  
    406       if (!$object instanceof sfController) 
    407       { 
    408         throw new sfFactoryException(sprintf('Class "%s" is not of the type "sfController".', $class)); 
    409       } 
    410  
    411       return $object; 
    412     } 
    413     catch (sfException $e) 
    414     { 
    415       $e->printStackTrace(); 
    416     } 
     383      $viewClassName = $this->context->getRequest()->getAttribute($moduleName.'_'.$actionName.'_view_name', sfConfig::get('mod_'.strtolower($moduleName).'_view_class'), 'symfony/action/view'); 
     384      $class    = sfAutoload::getClassPath($viewClassName.'View') ? $viewClassName.'View' : 'sfPHPView'; 
     385    } 
     386 
     387    return new $class($this->context, $moduleName, $actionName, $viewName); 
    417388  } 
    418389 
  • trunk/lib/database/sfDatabase.class.php

    r4890 r4957  
    2626    $connection      = null, 
    2727    $resource        = null; 
     28 
     29  /** 
     30   * Class constructor. 
     31   * 
     32   * @see initialize() 
     33   */ 
     34  public function __construct($parameters = array()) 
     35  { 
     36    $this->initialize($parameters); 
     37  } 
     38 
     39  /** 
     40   * Initializes this sfDatabase object. 
     41   * 
     42   * @param array An associative array of initialization parameters 
     43   * 
     44   * @return bool true, if initialization completes successfully, otherwise false 
     45   * 
     46   * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfDatabase object 
     47   */ 
     48  public function initialize($parameters = array()) 
     49  { 
     50    $this->parameterHolder = new sfParameterHolder(); 
     51    $this->parameterHolder->add($parameters); 
     52  } 
    2853 
    2954  /** 
     
    6994 
    7095    return $this->resource; 
    71   } 
    72  
    73   /** 
    74    * Initializes this sfDatabase object. 
    75    * 
    76    * @param array An associative array of initialization parameters 
    77    * 
    78    * @return bool true, if initialization completes successfully, otherwise false 
    79    * 
    80    * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfDatabase object 
    81    */ 
    82   public function initialize($parameters = array()) 
    83   { 
    84     $this->parameterHolder = new sfParameterHolder(); 
    85     $this->parameterHolder->add($parameters); 
    8696  } 
    8797 
  • trunk/lib/database/sfDatabaseManager.class.php

    r4597 r4957  
    2727 
    2828  /** 
     29   * Class constructor. 
     30   * 
     31   * @see initialize() 
     32   */ 
     33  public function __construct() 
     34  { 
     35    $this->initialize(); 
     36  } 
     37 
     38  /** 
     39   * Initializes this sfDatabaseManager object 
     40   * 
     41   * @return bool true, if initialization completes successfully, otherwise false 
     42   * 
     43   * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfDatabaseManager object 
     44   */ 
     45  public function initialize() 
     46  { 
     47    // load database configuration 
     48    require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/databases.yml')); 
     49  } 
     50 
     51  /** 
    2952   * Retrieves the database connection associated with this sfDatabase implementation. 
    3053   * 
     
    4770 
    4871  /** 
    49    * Initializes this sfDatabaseManager object 
    50    * 
    51    * @return bool true, if initialization completes successfully, otherwise false 
    52    * 
    53    * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfDatabaseManager object 
    54    */ 
    55   public function initialize() 
    56   { 
    57     // load database configuration 
    58     require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/databases.yml')); 
    59   } 
    60  
    61   /** 
    6272   * Executes the shutdown procedure 
    6373   * 
  • trunk/lib/filter/sfBasicSecurityFilter.class.php

    r4593 r4957  
    2121 * @version    SVN: $Id$ 
    2222 */ 
    23 class sfBasicSecurityFilter extends sfSecurityFilter 
     23class sfBasicSecurityFilter extends sfFilter 
    2424{ 
    2525  /** 
  • trunk/lib/filter/sfExecutionFilter.class.php

    r4951 r4957  
    116116    { 
    117117      // create validator manager 
    118       $validatorManager = new sfValidatorManager(); 
    119       $validatorManager->initialize($this->context); 
     118      $validatorManager = new sfValidatorManager($this->context); 
    120119 
    121120      require($validateFile); 
     
    227226    // get the view instance 
    228227    $view = $controller->getView($moduleName, $actionName, $viewName); 
    229     $view->initialize($this->context, $moduleName, $actionName, $viewName); 
    230228 
    231229    // execute the view 
     
    265263    { 
    266264      // register the fill in form filter 
    267       $fillInFormFilter = new sfFillInFormFilter(); 
    268       $fillInFormFilter->initialize($this->context, isset($parameters['param']) ? $parameters['param'] : array()); 
     265      $fillInFormFilter = new sfFillInFormFilter($this->context, isset($parameters['param']) ? $parameters['param'] : array()); 
    269266      $filterChain->register($fillInFormFilter); 
    270267    } 
  • trunk/lib/filter/sfFilter.class.php

    r3525 r4957  
    2929 
    3030  /** 
     31   * Class constructor. 
     32   * 
     33   * @see initialize() 
     34   */ 
     35  public function __construct($context, $parameters = array()) 
     36  { 
     37    $this->initialize($context, $parameters); 
     38  } 
     39 
     40  /** 
     41   * Initializes this Filter. 
     42   * 
     43   * @param sfContext The current application context 
     44   * @param array   An associative array of initialization parameters 
     45   * 
     46   * @return boolean true, if initialization completes successfully, otherwise false 
     47   * 
     48   * @throws <b>sfInitializationException</b> If an error occurs while initializing this Filter 
     49   */ 
     50  public function initialize($context, $parameters = array()) 
     51  { 
     52    $this->context = $context; 
     53 
     54    $this->parameterHolder = new sfParameterHolder(); 
     55    $this->parameterHolder->add($parameters); 
     56 
     57    return true; 
     58  } 
     59 
     60  /** 
    3161   * Returns true if this is the first call to the sfFilter instance. 
    3262   * 
     
    5686  { 
    5787    return $this->context; 
    58   } 
    59  
    60   /** 
    61    * Initializes this Filter. 
    62    * 
    63    * @param sfContext The current application context 
    64    * @param array   An associative array of initialization parameters 
    65    * 
    66    * @return boolean true, if initialization completes successfully, otherwise false 
    67    * 
    68    * @throws <b>sfInitializationException</b> If an error occurs while initializing this Filter 
    69    */ 
    70   public function initialize($context, $parameters = array()) 
    71   { 
    72     $this->context = $context; 
    73  
    74     $this->parameterHolder = new sfParameterHolder(); 
    75     $this->parameterHolder->add($parameters); 
    76  
    77     return true; 
    7888  } 
    7989 
  • trunk/lib/generator/sfGenerator.class.php

    r4951 r4957  
    2727 
    2828  /** 
     29   * Class constructor. 
     30   * 
     31   * @see initialize() 
     32   */ 
     33  public function __construct(sfGeneratorManager $generatorManager) 
     34  { 
     35    $this->initialize($generatorManager); 
     36  } 
     37 
     38  /** 
    2939   * Initializes the current sfGenerator instance. 
    3040   * 
  • trunk/lib/generator/sfGeneratorManager.class.php

    r4578 r4957  
    1919class sfGeneratorManager 
    2020{ 
     21  /** 
     22   * Class constructor. 
     23   * 
     24   * @see initialize() 
     25   */ 
     26  public function __construct() 
     27  { 
     28    $this->initialize(); 
     29  } 
     30 
    2131  /** 
    2232   * Initializes the sfGeneratorManager instance.