Development

Changeset 4957

You must first sign up to be able to contribute.

Changeset 4957

Show
Ignore:
Timestamp:
09/03/07 10:58:56 (2 years 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. 
     
    5060  public function generate($generator_class, $param) 
    5161  { 
    52     $generator = new $generator_class(); 
    53     $generator->initialize($this); 
     62    $generator = new $generator_class($this); 
    5463 
    5564    return $generator->generate($param); 
  • trunk/lib/helper/PartialHelper.php

    r4951 r4957  
    132132  $componentInstance = $controller->getComponent($moduleName, $componentName); 
    133133 
    134   // initialize the action 
    135   if (!$componentInstance->initialize($context)) 
    136   { 
    137     // component failed to initialize 
    138     throw new sfInitializationException(sprintf('Component initialization failed for module "%s", component "%s".', $moduleName, $componentName)); 
    139   } 
    140  
    141134  // load component's module config file 
    142135  require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/module.yml')); 
     
    178171  { 
    179172    // render 
    180     $view = new sfPartialView(); 
    181     $view->initialize($context, $moduleName, $actionName, ''); 
    182  
     173    $view = new sfPartialView($context, $moduleName, $actionName, ''); 
    183174    $view->getAttributeHolder()->add($componentInstance->getVarHolder()->getAll()); 
    184175 
     
    258249  } 
    259250 
    260   $view = new sfPartialView(); 
    261   $view->initialize($context, $moduleName, $actionName, ''); 
     251  $view = new sfPartialView($context, $moduleName, $actionName, ''); 
    262252  $view->getAttributeHolder()->add($vars); 
    263253 
  • trunk/lib/i18n/extract/sfI18nExtract.class.php

    r4576 r4957  
    2626 
    2727  /** 
     28   * Class constructor. 
     29   * 
     30   * @see initialize() 
     31   */ 
     32  public function __construct($culture, $parameters = array()) 
     33  { 
     34    $this->initialize($culture, $parameters); 
     35  } 
     36 
     37  /** 
    2838   * Initializes the current extract object. 
    2939   * 
  • trunk/lib/i18n/sfI18N.class.php

    r4951 r4957  
    2727 
    2828  /** 
     29   * Class constructor. 
     30   * 
     31   * @see initialize() 
     32   */ 
     33  public function __construct($context, sfCache $cache = null) 
     34  { 
     35    $this->initialize($context, $cache); 
     36  } 
     37 
     38  /** 
    2939   * Initializes this class. 
    3040   * 
  • trunk/lib/log/sfLogger.class.php

    r4951 r4957  
    4242 
    4343  /** 
    44    * Retrieves a new sfLogger implementation instance. 
    45    * 
    46    * @param string A sfLogger implementation name 
    47    * 
    48    * @return User A sfLogger implementation instance. 
    49    * 
    50    * @throws <b>sfFactoryException</b> If a logger implementation instance cannot 
    51    */ 
    52   public static function newInstance($class) 
    53   { 
    54     $object = new $class(); 
    55  
    56     if ($object instanceof sfLoggerInterface) 
    57     { 
    58       return new sfLoggerWrapper($object); 
    59     } 
    60  
    61     if (!$object instanceof sfLogger) 
    62     { 
    63       throw new sfFactoryException(sprintf('Class "%s" is not of the type sfLogger.', $class)); 
    64     } 
    65  
    66     return $object; 
     44   * Class constructor. 
     45   * 
     46   * @see initialize() 
     47   */ 
     48  public function __construct(sfEventDispatcher $dispatcher, $options = array()) 
     49  { 
     50    $this->initialize($dispatcher, $options); 
    6751  } 
    6852 
  • trunk/lib/request/sfRequest.class.php

    r4951 r4957  
    6868 
    6969  /** 
     70   * Class constructor. 
     71   * 
     72   * @see initialize() 
     73   */ 
     74  public function __construct(sfEventDispatcher $dispatcher, $parameters = array(), $attributes = array()) 
     75  { 
     76    $this->initialize($dispatcher, $parameters, $attributes); 
     77  } 
     78 
     79  /** 
    7080   * Initializes this sfRequest. 
    7181   * 
     
    179189  { 
    180190    return count($this->errors) > 0; 
    181   } 
    182  
    183   /** 
    184    * Retrieves a new sfRequest implementation instance. 
    185    * 
    186    * @param string A sfRequest implementation name 
    187    * 
    188    * @return sfRequest A sfRequest implementation instance 
    189    * 
    190    * @throws <b>sfFactoryException</b> If a request implementation instance cannot be created 
    191    */ 
    192   public static function newInstance($class) 
    193   { 
    194     $object = new $class(); 
    195  
    196     if (!$object instanceof sfRequest) 
    197     { 
    198       throw new sfFactoryException(sprintf('Class "%s" is not of the type sfRequest.', $class)); 
    199     } 
    200  
    201     return $object; 
    202191  } 
    203192 
  • trunk/lib/response/sfResponse.class.php

    r4951 r4957  
    2626 
    2727  /** 
     28   * Class constructor. 
     29   * 
     30   * @see initialize() 
     31   */ 
     32  public function __construct(sfEventDispatcher $dispatcher, $parameters = array()) 
     33  { 
     34    $this->initialize($dispatcher, $parameters); 
     35  } 
     36 
     37  /** 
    2838   * Initializes this sfResponse. 
    2939   * 
     
    4151    $this->parameterHolder = new sfParameterHolder(); 
    4252    $this->parameterHolder->add($parameters); 
    43   } 
    44  
    45   /** 
    46    * Retrieves a new sfResponse implementation instance. 
    47    * 
    48    * @param string A sfResponse implementation name 
    49    * 
    50    * @return sfResponse A sfResponse implementation instance 
    51    * 
    52    * @throws <b>sfFactoryException</b> If a response implementation instance cannot be created 
    53    */ 
    54   public static function newInstance($class) 
    55   { 
    56     $object = new $class(); 
    57  
    58     if (!$object instanceof sfResponse) 
    59     { 
    60       throw new sfFactoryException(sprintf('Class "%s" is not of the type sfResponse.', $class)); 
    61     } 
    62  
    63     return $object; 
    6453  } 
    6554 
  • trunk/lib/routing/sfPatternRouting.class.php

    r4951 r4957  
    4545 
    4646    $this->setDefaultSuffix($this->parameterHolder->get('suffix')); 
    47  
    48     if ($this->parameterHolder->get('load_configuration', false)) 
    49     { 
    50       if ($config = sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/routing.yml', true)) 
    51       { 
    52         include($config); 
    53       } 
     47  } 
     48 
     49  /** 
     50   * Loads routing configuration. 
     51   */ 
     52  public function loadConfiguration() 
     53  { 
     54    if ($config = sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/routing.yml', true)) 
     55    { 
     56      include($config); 
    5457    } 
    5558  } 
  • trunk/lib/routing/sfRouting.class.php

    r4951 r4957  
    2525 
    2626  /** 
    27    * Retrieves a new sfRouting implementation instance
     27   * Class constructor
    2828   * 
    29    * @param string A sfRouting implementation name 
    30    * 
    31    * @return sfRouting A sfRouting implementation instance. 
    32    * 
    33    * @throws <b>sfFactoryException</b> If a routing implementation instance cannot be created 
     29   * @see initialize() 
    3430   */ 
    35   public static function newInstance($class
     31  public function __construct(sfEventDispatcher $dispatcher, $parameters = array()
    3632  { 
    37     $object = new $class(); 
    38  
    39     if (!$object instanceof sfRouting) 
    40     { 
    41       throw new sfFactoryException(sprintf('Class "%s" is not of the type sfRouting.', $class)); 
    42     } 
    43  
    44     return $object; 
     33    $this->initialize($dispatcher, $parameters); 
    4534  } 
    4635 
  • trunk/lib/storage/sfStorage.class.php

    r4890 r4957  
    2525 
    2626  /** 
     27   * Class constructor. 
     28   * 
     29   * @see initialize() 
     30   */ 
     31  public function __construct($parameters = array()) 
     32  { 
     33    $this->initialize($parameters); 
     34  } 
     35 
     36  /** 
    2737   * Initializes this Storage instance. 
    2838   * 
     
    3747    $this->parameterHolder = new sfParameterHolder(); 
    3848    $this->getParameterHolder()->add($parameters); 
    39   } 
    40  
    41   /** 
    42    * Retrieves a new sfStorage implementation instance. 
    43    * 
    44    * @param string A sfStorage implementation name 
    45    * 
    46    * @return sfStorage A sfStorage implementation instance 
    47    * 
    48    * @throws <b>sfFactoryException</b> If a storage implementation instance cannot be created 
    49    */ 
    50   public static function newInstance($class) 
    51   { 
    52     $object = new $class(); 
    53  
    54     if (!$object instanceof sfStorage) 
    55     { 
    56       throw new sfFactoryException(sprintf('Class "%s" is not of the type sfStorage.', $class)); 
    57     } 
    58  
    59     return $object; 
    6049  } 
    6150 
  • trunk/lib/task/propel/sfPropelDataDumpTask.class.php

    r4743 r4957  
    6666 
    6767    $databaseManager = new sfDatabaseManager(); 
    68     $databaseManager->initialize(); 
    6968 
    7069    if (!sfToolkit::isPathAbsolute($filename)) 
  • trunk/lib/task/propel/sfPropelDataLoadTask.class.php

    r4942 r4957  
    9191 
    9292    $databaseManager = new sfDatabaseManager(); 
    93     $databaseManager->initialize(); 
    9493 
    9594    $data = new sfPropelData(); 
  • trunk/lib/task/propel/sfPropelGenerateCrudTask.class.php

    r4743 r4957  
    6666    sfConfig::set('sf_module_cache_dir', $tmpDir); 
    6767    $generatorManager = new sfGeneratorManager(); 
    68     $generatorManager->initialize(); 
    6968    $generatorManager->generate('sfPropelCrudGenerator', array('model_class' => $arguments['model'], 'moduleName' => $arguments['module'], 'theme' => $options['theme'])); 
    7069 
  • trunk/lib/task/sfTask.class.php

    r4845 r4957  
    3434   * @param sfCommandApplication A sfCommandApplication object 
    3535   */ 
    36   public function __construct(sfCommandApplication $commandApplication = null) 
     36  public function __construct(sfCommandApplication $commandApplication = null, sfLogger $logger = null) 
     37  { 
     38    $this->initialize($commandApplication, $logger); 
     39 
     40    $this->configure(); 
     41  } 
     42 
     43  /** 
     44   * Initializes the sfTask instance. 
     45   * 
     46   * @param sfCommandApplication A sfCommandApplication instance 
     47   * @param sfLogger             A sfLogger instance 
     48   * 
     49   * @throws <b>sfFactoryException</b> If a task implementation instance cannot 
     50   */ 
     51  public function initialize(sfCommandApplication $commandApplication = null, sfLogger $logger = null) 
    3752  { 
    3853    $this->commandApplication = $commandApplication; 
    39  
    40     $this->configure(); 
    41   } 
    42  
    43   /** 
    44    * Retrieves a new sfTask implementation instance. 
    45    * 
    46    * @param string A sfTask implementation name 
    47    * 
    48    * @return User A sfTask implementation instance. 
    49    * 
    50    * @throws <b>sfFactoryException</b> If a task implementation instance cannot 
    51    */ 
    52   public static function newInstance($class, sfCommandApplication $commandApplication = null, sfLogger $logger = null) 
    53   { 
    54     $object = new $class(); 
    55  
    56     if (!$object instanceof sfTask) 
    57     { 
    58       throw new sfFactoryException(sprintf('Class "%s" is not of the type sfTask.', $class)); 
    59     } 
    60  
    61     $object->commandApplication = $commandApplication; 
    62     $object->setLogger($logger); 
    63  
    64     return $object; 
     54    $this->setLogger($logger); 
    6555  } 
    6656 
  • trunk/lib/user/sfUser.class.php

    r4951 r4957  
    4040 
    4141  /** 
     42   * Class constructor. 
     43   * 
     44   * @see initialize() 
     45   */ 
     46  public function __construct(sfEventDispatcher $dispatcher, sfStorage $storage, $parameters = array()) 
     47  { 
     48    $this->initialize($dispatcher, $storage, $parameters); 
     49  } 
     50 
     51  /** 
    4252   * Initializes this sfUser. 
    4353   * 
     
    7585    //  - use the default culture set in i18n.yml 
    7686    $currentCulture = $storage->read(self::CULTURE_NAMESPACE); 
    77     $culture = $this->parameterHolder->get('culture', !is_null($currentCulture) ? $currentCulture : $this->parameterHolder->get('default_culture', 'en')); 
    78  
    79     $this->setCulture($culture); 
     87    $this->setCulture($this->parameterHolder->get('culture', !is_null($currentCulture) ? $currentCulture : $this->parameterHolder->get('default_culture', 'en'))); 
    8088 
    8189    // flag current flash to be removed at shutdown 
     
    95103 
    96104  /** 
    97    * Retrieve a new sfUser implementation instance. 
    98    * 
    99    * @param string A sfUser implementation name 
    100    * 
    101    * @return User A sfUser implementation instance. 
    102    * 
    103    * @throws <b>sfFactoryException</b> If a user implementation instance cannot 
    104    */ 
    105   public static function newInstance($class) 
    106   { 
    107     $object = new $class(); 
    108  
    109     if (!$object instanceof sfUser) 
    110     { 
    111       throw new sfFactoryException(sprintf('Class "%s" is not of the type sfUser.', $class)); 
    112     } 
    113  
    114     return $object; 
    115   } 
    116  
    117   /** 
    118    * Sets culture. 
     105   * Sets the user culture. 
    119106   * 
    120107   * @param  string culture 
  • trunk/lib/util/sfContext.class.php

    r4951 r4957  
    4242      // setup our database connections 
    4343      $this->factories['databaseManager'] = new sfDatabaseManager(); 
    44       $this->factories['databaseManager']->initialize(); 
    4544    } 
    4645 
  • trunk/lib/validator/sfValidator.class.php

    r3250 r4957  
    2626 
    2727  /** 
    28    * Executes this validator. 
     28   * Class constructor. 
    2929   * 
    30    * @param mixed A file or parameter value/array 
    31    * @param string An error message reference 
    32    * 
    33    * @return bool true, if this validator executes successfully, otherwise false 
     30   * @see initialize() 
    3431   */ 
    35   abstract function execute(&$value, &$error); 
    36  
    37   /** 
    38    * Retrieves the current application context. 
    39    * 
    40    * @return sfContext The current sfContext instance 
    41    */ 
    42   public final function getContext() 
     32  public function __construct($context, $parameters = array()) 
    4333  { 
    44     return $this->context
     34    $this->initialize($context, $parameters)
    4535  } 
    4636 
     
    6151 
    6252    return true; 
     53  } 
     54 
     55  /** 
     56   * Executes this validator. 
     57   * 
     58   * @param mixed A file or parameter value/array 
     59   * @param string An error message reference 
     60   * 
     61   * @return bool true, if this validator executes successfully, otherwise false 
     62   */ 
     63  abstract function execute(&$value, &$error); 
     64 
     65  /** 
     66   * Retrieves the current application context. 
     67   * 
     68   * @return sfContext The current sfContext instance 
     69   */ 
     70  public final function getContext() 
     71  { 
     72    return $this->context; 
    6373  } 
    6474 
  • trunk/lib/validator/sfValidatorManager.class.php

    r4951 r4957  
    2828 
    2929  /** 
     30   * Class constructor. 
     31   * 
     32   * @see initialize() 
     33   */ 
     34  public function __construct($context) 
     35  { 
     36    $this->initialize($context); 
     37  } 
     38 
     39  /** 
     40   * Initializes this validator manager. 
     41   * 
     42   * @param sfContext A sfContext instance 
     43   */ 
     44  public function initialize($context) 
     45  { 
     46    $this->request = $context->getRequest(); 
     47  } 
     48 
     49  /** 
    3050   * Clears this validator manager so it can be reused. 
    3151   */ 
     
    102122 
    103123  /** 
    104    * Initializes this validator manager. 
    105    * 
    106    * @param sfContext A sfContext instance 
    107    */ 
    108   public function initialize($context) 
    109   { 
    110     $this->request = $context->getRequest(); 
    111   } 
    112  
    113   /** 
    114124   * Registers a file or parameter. 
    115125   * 
  • trunk/lib/view/sfView.class.php

    r4951 r4957  
    8686 
    8787  /** 
    88    * Executes any presentation logic and set template attributes. 
    89    */ 
    90   abstract function execute(); 
    91  
    92   /** 
    93    * Configures template. 
    94    */ 
    95   abstract function configure(); 
    96  
    97   /** 
    98    * Retrieves this views decorator template directory. 
    99    * 
    100    * @return string An absolute filesystem path to this views decorator template directory 
    101    */ 
    102   public function getDecoratorDirectory() 
    103   { 
    104     return $this->decoratorDirectory; 
    105   } 
    106  
    107   /** 
    108    * Retrieves this views decorator template. 
    109    * 
    110    * @return string A template filename, if a template has been set, otherwise null 
    111    */ 
    112   public function getDecoratorTemplate() 
    113   { 
    114     return $this->decoratorTemplate; 
    115   } 
    116  
    117   /** 
    118    * Retrieves this view template directory. 
    119    * 
    120    * @return string An absolute filesystem path to this views template directory 
    121    */ 
    122   public function getDirectory() 
    123   { 
    124     return $this->directory; 
    125   } 
    126  
    127   /** 
    128    * Retrieves the template engine associated with this view. 
    129    * 
    130    * Note: This will return null for PHPView instances. 
    131    * 
    132    * @return mixed A template engine instance 
    133    */ 
    134   abstract function getEngine(); 
    135  
    136   /** 
    137    * Retrieves this views template. 
    138    * 
    139    * @return string A template filename, if a template has been set, otherwise null 
    140    */ 
    141   public function getTemplate() 
    142   { 
    143     return $this->template; 
     88   * Class constructor. 
     89   * 
     90   * @see initialize() 
     91   */ 
     92  public function __construct($context, $moduleName, $actionName, $viewName) 
     93  { 
     94    $this->initialize($context, $moduleName, $actionName, $viewName); 
    14495  } 
    14596 
     
    186137 
    187138  /** 
     139   * Executes any presentation logic and set template attributes. 
     140   */ 
     141  abstract function execute(); 
     142 
     143  /** 
     144   * Configures template. 
     145   */ 
     146  abstract function configure(); 
     147 
     148  /** 
     149   * Retrieves this views decorator template directory. 
     150   * 
     151   * @return string An absolute filesystem path to this views decorator template directory 
     152   */ 
     153  public function getDecoratorDirectory() 
     154  { 
     155    return $this->decoratorDirectory; 
     156  } 
     157 
     158  /** 
     159   * Retrieves this views decorator template. 
     160   * 
     161   * @return string A template filename, if a template has been set, otherwise null 
     162   */ 
     163  public function getDecoratorTemplate() 
     164  { 
     165    return $this->decoratorTemplate; 
     166  } 
     167 
     168  /** 
     169   * Retrieves this view template directory. 
     170   * 
     171   * @return string An absolute filesystem path to this views template directory 
     172   */ 
     173  public function getDirectory() 
     174  { 
     175    return $this->directory; 
     176  } 
     177 
     178  /** 
     179   * Retrieves the template engine associated with this view. 
     180   * 
     181   * Note: This will return null for PHPView instances. 
     182   * 
     183   * @return mixed A template engine instance 
     184   */ 
     185  abstract function getEngine(); 
     186 
     187  /** 
     188   * Retrieves this views template. 
     189   * 
     190   * @return string A template filename, if a template has been set, otherwise null 
     191   */ 
     192  public function getTemplate() 
     193  { 
     194    return $this->template; 
     195  } 
     196 
     197  /** 
    188198   * Retrieves attributes for the current view. 
    189199   * 
  • trunk/lib/view/sfViewCacheManager.class.php

    r4951 r4957  
    3333 
    3434  /** 
     35   * Class constructor. 
     36   * 
     37   * @see initialize() 
     38   */ 
     39  public function __construct($context, sfCache $cache) 
     40  { 
     41    $this->initialize($context, $cache); 
     42  } 
     43 
     44  /** 
    3545   * Initializes the cache manager. 
    3646   * 
  • trunk/test/unit/action/sfComponentTest.php

    r4951 r4957  
    2626// ->initialize() 
    2727$t->diag('->initialize()'); 
    28 $component = new myComponent(); 
    29 $t->is($component->getContext(), null, '->initialize() takes a sfContext object as its first argument'); 
     28$component = new myComponent($context); 
     29$t->is($component->getContext(), $context, '->initialize() takes a sfContext object as its first argument'); 
    3030$component->initialize($context); 
    3131$t->is($component->getContext(), $context, '->initialize() takes a sfContext object as its first argument'); 
  • trunk/test/unit/cache/sfAPCCacheTest.php

    r4579 r4957  
    3333// ->initialize() 
    3434$t->diag('->initialize()'); 
    35 $cache = sfCache::newInstance('sfAPCCache'); 
     35$cache = new sfAPCCache(); 
    3636$cache->initialize(); 
    3737 
  • trunk/test/unit/cache/sfCacheTest.php

    r4579 r4957  
    2727} 
    2828 
    29 $t = new lime_test(4, new lime_output_color()); 
    30  
    31 // ::newInstance() 
    32 $t->diag('::newInstance()'); 
    33 $t->isa_ok(sfCache::newInstance('myCache'), 'myCache', '::newInstance() takes a cache class as its first parameter'); 
    34 $t->isa_ok(sfCache::newInstance('myCache'), 'myCache', '::newInstance() returns an instance of myCache'); 
    35  
    36 try 
    37 
    38   sfCache::newInstance('fakeCache'); 
    39   $t->fail('::newInstance() throws a sfFactoryException if the class does not extends sfCache'); 
    40 
    41 catch (sfFactoryException $e) 
    42 
    43   $t->pass('::newInstance() throws a sfFactoryException if the class does not extends sfCache'); 
    44 
     29$t = new lime_test(1, new lime_output_color()); 
    4530 
    4631// ->initialize() 
    4732$t->diag('->initialize()'); 
    48 $cache = sfCache::newInstance('myCache'); 
     33$cache = new myCache(); 
    4934$cache->initialize(array('foo' => 'bar')); 
    5035$t->is($cache->getParameterHolder()->get('foo'), 'bar', '->initialize() takes an array of parameters as its first argument'); 
  • trunk/test/unit/cache/sfEAcceleratorCacheTest.php

    r4579 r4957  
    2727// ->initialize() 
    2828$t->diag('->initialize()'); 
    29 $cache = sfCache::newInstance('sfEAcceleratorCache'); 
     29$cache = new sfEAcceleratorCache(); 
    3030$cache->initialize(); 
    3131 
  • trunk/test/unit/cache/sfFileCacheTest.php

    r4579 r4957  
    2222// ->initialize() 
    2323$t->diag('->initialize()'); 
    24 $cache = sfCache::newInstance('sfFileCache'); 
    2524try 
    2625{ 
    27   $cache->initialize(); 
     26  $cache = new sfFileCache(); 
    2827  $t->fail('->initialize() throws an sfInitializationException exception if you don\'t pass a "cacheDir" parameter'); 
    2928} 
     
    3332} 
    3433 
    35 $cache = sfCache::newInstance('sfFileCache'); 
    36 $cache->initialize(array('cacheDir' => $temp)); 
     34$cache = new sfFileCache(array('cacheDir' => $temp)); 
    3735 
    3836sfCacheDriverTests::launch($t, $cache); 
  • trunk/test/unit/cache/sfMemcacheCacheTest.php

    r4658 r4957  
    2727// ->initialize() 
    2828$t->diag('->initialize()'); 
    29 $cache = sfCache::newInstance('sfMemcacheCache'); 
     29$cache = new sfMemcacheCache(); 
    3030try 
    3131{ 
  • trunk/test/unit/cache/sfNoCacheTest.php

    r4579 r4957  
    1515// ->initialize() 
    1616$t->diag('->initialize()'); 
    17 $cache = sfCache::newInstance('sfNoCache'); 
     17$cache = new sfNoCache(); 
    1818$cache->initialize(); 
    1919 
  • trunk/test/unit/cache/sfSQLiteCacheTest.php

    r4579 r4957  
    2323// ->initialize() 
    2424$t->diag('->initialize()'); 
    25 $cache = sfCache::newInstance('sfSQLiteCache'); 
    2625try 
    2726{ 
    28   $cache->initialize(); 
     27  $cache = new sfSQLiteCache(); 
    2928  $t->fail('->initialize() throws an sfInitializationException exception if you don\'t pass a "database" parameter'); 
    3029} 
     
    3534 
    3635// database in memory 
    37 $cache = sfCache::newInstance('sfSQLiteCache'); 
    38 $cache->initialize(array('database' => ':memory:')); 
     36$cache = new sfSQLiteCache(array('database' => ':memory:')); 
    3937 
    4038sfCacheDriverTests::launch($t, $cache); 
     
    4341$database = tempnam('/tmp/cachedir', 'tmp'); 
    4442unlink($database); 
    45 $cache = sfCache::newInstance('sfSQLiteCache'); 
    46 $cache->initialize(array('database' => $database)); 
     43$cache = new sfSQLiteCache(array('database' => $database)); 
    4744sfCacheDriverTests::launch($t, $cache); 
    4845unlink($database); 
  • trunk/test/unit/cache/sfXCacheCacheTest.php

    r4579 r4957  
    2727// ->initialize() 
    2828$t->diag('->initialize()'); 
    29 $cache = sfCache::newInstance('sfXCacheCache'); 
     29$cache = new sfXCacheCache(); 
    3030$cache->initialize(); 
    3131 
  • trunk/test/unit/config/fixtures/sfFilterConfigHandler/result.php

    r2661 r4957  
    55list($class, $parameters) = (array) sfConfig::get('sf_execution_filter', array('sfExecutionFilter', array ( 
    66))); 
    7 $filter = new $class(); 
    8 $filter->initialize($this->context, $parameters); 
     7$filter = new $class($this->context, $parameters); 
    98$filterChain->register($filter); 
    109 
    1110list($class, $parameters) = (array) sfConfig::get('sf_default_filter', array('defaultFilterClass', null)); 
    12 $filter = new $class(); 
    13 $filter->initialize($this->context, $parameters); 
     11$filter = new $class($this->context, $parameters); 
    1412$filterChain->register($filter); 
    1513 
     
    1715  'key' => 'value', 
    1816))); 
    19 $filter = new $class(); 
    20 $filter->initialize($this->context, $parameters); 
     17$filter = new $class($this->context, $parameters); 
    2118$filterChain->register($filter); 
    2219 
     
    2421  'key' => 'value', 
    2522))); 
    26 $filter = new $class(); 
    27 $filter->initialize($this->context, $parameters); 
     23$filter = new $class($this->context, $parameters); 
    2824$filterChain->register($filter); 
    2925 
  • trunk/test/unit/controller/sfControllerTest.php

    r4951 r4957  
    2121$context = sfContext::getInstance(); 
    2222 
    23 $controller = new myController(); 
    24 $controller->initialize($context); 
     23$controller = new myController($context); 
    2524 
    2625// new methods via sfEventDispatcher 
  • trunk/test/unit/controller/sfWebControllerTest.php

    r4951 r4957  
    2424)); 
    2525 
    26 $controller = sfController::newInstance('sfFrontWebController'); 
    27 $controller->initialize($context, null); 
     26$controller = new sfFrontWebController($context, null); 
    2827 
    2928$tests = array( 
  • trunk/test/unit/generator/sfGeneratorTest.php

    r4951 r4957  
    1919 
    2020$manager = new sfGeneratorManager(); 
    21 $generator = new myGenerator(); 
    22 $generator->initialize($manager); 
     21$generator = new myGenerator($manager); 
  • trunk/test/unit/log/sfAggregateLoggerTest.php

    r4951 r4957  
    2121  unlink($file); 
    2222} 
    23 $fileLogger = sfLogger::newInstance('sfFileLogger'); 
    24 $fileLogger->initialize($dispatcher, array('file' => $file)); 
    25 $consoleLogger = sfLogger::newInstance('sfConsoleLogger'); 
     23$fileLogger = new sfFileLogger($dispatcher, array('file' => $file)); 
     24$consoleLogger = new sfConsoleLogger($dispatcher); 
    2625 
    2726// ->initialize() 
    2827$t->diag('->initialize()'); 
    29 $logger = sfLogger::newInstance('sfAggregateLogger'); 
    30 $logger->initialize($dispatcher, array('loggers' => $fileLogger)); 
     28$logger = new sfAggregateLogger($dispatcher, array('loggers' => $fileLogger)); 
    3129$t->is($logger->getLoggers(), array($fileLogger), '->initialize() can take a "loggers" parameter'); 
    3230 
    33 $logger = sfLogger::newInstance('sfAggregateLogger'); 
    34 $logger->initialize($dispatcher, array('loggers' => array($fileLogger, $consoleLogger))); 
     31$logger = new sfAggregateLogger($dispatcher, array('loggers' => array($fileLogger, $consoleLogger))); 
    3532$t->is($logger->getLoggers(), array($fileLogger, $consoleLogger), '->initialize() can take a "loggers" parameter'); 
    3633 
     
    4542 
    4643// ->getLoggers() ->addLoggers() ->addLogger() 
    47 $logger = sfLogger::newInstance('sfAggregateLogger'); 
     44$logger = new sfAggregateLogger($dispatcher); 
    4845$logger->addLogger($fileLogger); 
    4946$t->is($logger->getLoggers(), array($fileLogger), '->addLogger() adds a new sfLogger instance'); 
    5047 
    51 $logger = sfLogger::newInstance('sfAggregateLogger'); 
     48$logger = new sfAggregateLogger($dispatcher); 
    5249$logger->addLoggers(array($fileLogger, $consoleLogger)); 
    5350$t->is($logger->getLoggers(), array($fileLogger, $consoleLogger), '->addLoggers() adds an array of sfLogger instances'); 
  • trunk/test/unit/log/sfConsoleLoggerTest.php

    r4845 r4957  
    1313$t = new lime_test(1, new lime_output_color()); 
    1414 
    15 $logger = sfLogger::newInstance('sfConsoleLogger'); 
     15$logger = new sfConsoleLogger(new sfEventDispatcher()); 
    1616ob_start(); 
    1717$logger->log('foo'); 
  • trunk/test/unit/log/sfFileLoggerTest.php

    r4951 r4957  
    2424// ->initialize() 
    2525$t->diag('->initialize()'); 
    26 $logger = sfLogger::newInstance('sfFileLogger'); 
    2726try 
    2827{ 
    29   $logger->initialize($dispatcher); 
     28  $logger = new sfFileLogger($dispatcher); 
    3029  $t->fail('->initialize() parameters must contains a "file" parameter'); 
    3130} 
     
    3736// ->log() 
    3837$t->diag('->log()'); 
    39 $logger->initialize($dispatcher, array('file' => $file)); 
     38$logger = new sfFileLogger($dispatcher, array('file' => $file)); 
    4039$logger->log('foo'); 
    4140$lines = explode("\n", file_get_contents($file)); 
  • trunk/test/unit/log/sfLoggerTest.php

    r4951 r4957  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(137, new lime_output_color()); 
     13$t = new lime_test(135, new lime_output_color()); 
    1414 
    1515class myLogger extends sfLogger 
     
    2828 
    2929$dispatcher = new sfEventDispatcher(); 
    30  
    31 // ->newInstance() 
    32 $t->diag('->newInstance()'); 
    33 $logger = sfLogger::newInstance('myLogger'); 
    34 $t->isa_ok($logger, 'myLogger', '::getInstance() returns a sfLogger instance'); 
    35 try 
    36 
    37   sfLogger::newInstance('notaLogger'); 
    38   $t->fail('->newInstance() throws a sfFactoryException if the logger does not extend sfLogger'); 
    39 
    40 catch (sfFactoryException $e) 
    41 
    42   $t->pass('->newInstance() throws a sfFactoryException if the logger does not extend sfLogger'); 
    43 
     30$logger = new myLogger($dispatcher); 
    4431 
    4532// ->setLogLevel() ->getLogLevel() 
  • trunk/test/unit/request/sfRequestTest.php

    r4951 r4957  
    2323} 
    2424 
    25 $t = new lime_test(53, new lime_output_color()); 
     25$t = new lime_test(50, new lime_output_color()); 
    2626 
    2727$dispatcher = new sfEventDispatcher(); 
    2828 
    29 // ::newInstance() 
    30 $t->diag('::newInstance()'); 
    31 $t->isa_ok(sfRequest::newInstance('myRequest'), 'myRequest', '::newInstance() takes a request class as its first parameter'); 
    32 $t->isa_ok(sfRequest::newInstance('myRequest'), 'myRequest', '::newInstance() returns an instance of myRequest'); 
    33  
    34 try 
    35 { 
    36   sfRequest::newInstance('fakeRequest'); 
    37   $t->fail('::newInstance() throws a sfFactoryException if the class does not extends sfRequest'); 
    38 } 
    39 catch (sfFactoryException $e) 
    40 { 
    41   $t->pass('::newInstance() throws a sfFactoryException if the class does not extends sfRequest'); 
    42 } 
    43  
    4429// ->initialize() 
    4530$t->diag('->initialize()'); 
    46 $request = sfRequest::newInstance('myRequest'); 
    47 $request->initialize($dispatcher); 
     31$request = new myRequest($dispatcher); 
    4832$t->is($dispatcher, $request->getEventDispatcher(), '->initialize() takes a sfEventDispatcher object as its first argument'); 
    4933$request->initialize($dispatcher, array('foo' => 'bar')); 
     
    7256$t->is($request->extractParameters(array('bar')), array('bar' => 'bar'), '->extractParameters() returns parameters for keys in its first parameter'); 
    7357 
    74 $request = sfRequest::newInstance('myRequest'); 
    75 $request->initialize($dispatcher); 
     58$request = new myRequest($dispatcher); 
    7659 
    7760// ->setError() ->hasError() ->hasErrors() ->getError() ->removeError() ->getErrorNames 
  • trunk/test/unit/request/sfWebRequestTest.php

    r4440 r4957  
    2020} 
    2121 
    22 $request = sfRequest::newInstance('myRequest'); 
     22$dispatcher = new sfEventDispatcher(); 
     23$request = new myRequest($dispatcher); 
    2324 
    2425// ->getLanguages() 
  • trunk/test/unit/response/sfResponseTest.php

    r4951 r4957  
    2121} 
    2222 
    23 $t = new lime_test(23, new lime_output_color()); 
     23$t = new lime_test(20, new lime_output_color()); 
    2424 
    2525$dispatcher = new sfEventDispatcher(); 
    2626 
    27 // ::newInstance() 
    28 $t->diag('::newInstance()'); 
    29 $t->isa_ok(sfResponse::newInstance('myResponse'), 'myResponse', '::newInstance() takes a response class as its first parameter'); 
    30 $t->isa_ok(sfResponse::newInstance('myResponse'), 'myResponse', '::newInstance() returns an instance of myResponse'); 
    31  
    32 try 
    33 { 
    34   sfResponse::newInstance('fakeResponse'); 
    35   $t->fail('::newInstance() throws a sfFactoryException if the class does not extends sfResponse'); 
    36 } 
    37 catch (sfFactoryException $e) 
    38 { 
    39   $t->pass('::newInstance() throws a sfFactoryException if the class does not extends sfResponse'); 
    40 } 
    41  
    4227// ->initialize() 
    4328$t->diag('->initialize()'); 
    44 $response = sfResponse::newInstance('myResponse'); 
    45 $response->initialize($dispatcher, array('foo' => 'bar')); 
     29$response = new myResponse($dispatcher, array('foo' => 'bar')); 
    4630$t->is($response->getParameter('foo'), 'bar', '->initialize() takes an array of parameters as its second argument'); 
    4731 
     
    6145// ->serialize() ->unserialize() 
    6246$t->diag('->serialize() ->unserialize()'); 
    63 $t->ok(sfResponse::newInstance('myResponse') instanceof Serializable, 'sfResponse implements the Serializable interface'); 
     47$t->ok(new myResponse($dispatcher) instanceof Serializable, 'sfResponse implements the Serializable interface'); 
    6448 
    6549// parameter holder proxy 
    6650require_once($_test_dir.'/unit/sfParameterHolderTest.class.php'); 
    67 $response = sfResponse::newInstance('myResponse'); 
    68 $response->initialize($dispatcher); 
     51$response = new myResponse($dispatcher); 
    6952$pht = new sfParameterHolderProxyTest($t); 
    7053$pht->launchTests($response, 'parameter'); 
  • trunk/test/unit/response/sfWebResponseTest.php

    r4951 r4957  
    2828$dispatcher = new sfEventDispatcher(); 
    2929 
    30 $response = new myWebResponse(); 
    31 $response->initialize($dispatcher); 
     30$response = new myWebResponse($dispatcher); 
    3231 
    3332// ->getStatusCode() ->setStatusCode() 
     
    162161// ->mergeProperties() 
    163162$t->diag('->mergeProperties()'); 
    164 $response1 = sfResponse::newInstance('myWebResponse'); 
    165 $response1->initialize($dispatcher); 
    166 $response2 = sfResponse::newInstance('myWebResponse'); 
    167 $response2->initialize($dispatcher); 
     163$response1 = new myWebResponse($dispatcher); 
     164$response2 = new myWebResponse($dispatcher); 
    168165 
    169166$response1->setHttpHeader('symfony', 'foo'); 
     
    178175// ->addStylesheet() 
    179176$t->diag('->addStylesheet()'); 
    180 $response = sfResponse::newInstance('myWebResponse'); 
    181 $response->initialize($dispatcher); 
     177$response = new myWebResponse($dispatcher); 
    182178$response->addStylesheet('test'); 
    183179$t->ok($response->getParameterHolder()->has('test', 'helper/asset/auto/stylesheet'), '->addStylesheet() adds a new stylesheet for the response'); 
     
    199195// ->addJavascript() 
    200196$t->diag('->addJavascript()'); 
    201 $response = sfResponse::newInstance('myWebResponse'); 
    202 $response->initialize($dispatcher); 
     197$response = new myWebResponse($dispatcher); 
    203198$response->addJavascript('test'); 
    204199$t->ok($response->getParameterHolder()->has('test', 'helper/asset/auto/javascript'), '->addJavascript() adds a new javascript for the response'); 
     
    223218// ->setHeaderOnly() ->getHeaderOnly() 
    224219$t->diag('->setHeaderOnly() ->isHeaderOnly()'); 
    225 $response = sfResponse::newInstance('myWebResponse'); 
    226 $response->initialize($dispatcher); 
     220$response = new myWebResponse($dispatcher); 
    227221$t->is($response->isHeaderOnly(), false, '->isHeaderOnly() returns false if the content must be send to the client'); 
    228222$response->setHeaderOnly(true); 
  • trunk/test/unit/routing/sfNoRoutingTest.php

    r4951 r4957  
    1313$t = new lime_test(12, new lime_output_color()); 
    1414 
    15 $routing = new sfNoRouting(); 
    16 $routing->initialize(new sfEventDispatcher()); 
     15$routing = new sfNoRouting(new sfEventDispatcher()); 
    1716 
    1817// ->getCurrentInternalUri() 
  • trunk/test/unit/routing/sfPathInfoRoutingTest.php

    r4951 r4957  
    1313$t = new lime_test(12, new lime_output_color()); 
    1414 
    15 $routing = new sfPathInfoRouting(); 
    16 $routing->initialize(new sfEventDispatcher()); 
     15$routing = new sfPathInfoRouting(new sfEventDispatcher()); 
    1716 
    1817// ->getCurrentInternalUri() 
  • trunk/test/unit/routing/sfPatternRoutingTest.php

    r4951 r4957  
    2222 
    2323// public methods 
    24 $r = new sfPatternRoutingTest(); 
    25 $r->initialize(new sfEventDispatcher()); 
     24$r = new sfPatternRoutingTest(new sfEventDispatcher()); 
    2625foreach (array('clearRoutes', 'connect', 'generate', 'getCurrentInternalUri', 'getCurrentRouteName', 'getRoutes', 'hasRoutes', 'parse', 'setRoutes') as $method) 
    2726{ 
  • trunk/test/unit/sfContextMock.class.php

    r4951 r4957  
    2828      self::$instance = new sfContext(); 
    2929 
    30       self::$instance->storage = sfStorage::newInstance('sfSessionTestStorage'); 
    31       self::$instance->storage->initialize(array('session_path' => sfConfig::get('sf_test_cache_dir').'/sessions')); 
     30      self::$instance->storage = new sfSessionTestStorage(array('session_path' => sfConfig::get('sf_test_cache_dir').'/sessions')); 
    3231 
    3332      self::$instance->dispatcher = new sfEventDispatcher(); 
     
    8988  public function inject($type, $class, $parameters = array()) 
    9089  { 
    91     $object = new $class(); 
    92     if (method_exists($object, 'initialize')) 
     90    switch ($type) 
    9391    { 
    94       switch ($type) 
    95       { 
    96         case 'routing': 
    97         case 'response': 
    98           $object->initialize($this->dispatcher, $parameters); 
    99           break; 
    100         case 'request': 
    101           $object->initialize($this->dispatcher, $this->routing, $parameters); 
    102           break; 
    103         default: 
    104           $object->initialize($this, $parameters); 
    105       } 
     92      case 'routing': 
     93      case 'response': 
     94        $object = new $class($this->dispatcher, $parameters); 
     95        break; 
     96      case 'request': 
     97        $object = new $class($this->dispatcher, $this->routing, $parameters); 
     98        break; 
     99      default: 
     100        $object = new $class($this, $parameters); 
    106101    } 
     102 
    107103    $this->$type = $object; 
    108104  } 
  • trunk/test/unit/storage/sfNoStorageTest.php

    r4890 r4957  
    1414 
    1515// initialize the storage 
    16 $storage = sfStorage::newInstance('sfNoStorage'); 
    17 $storage->initialize(); 
     16$storage = new sfNoStorage(); 
    1817 
    1918$t->ok($storage instanceof sfStorage, 'sfNoStorage is an instance of sfStorage'); 
  • trunk/test/unit/storage/sfPDOSessionStorageTest.php

    r4890 r4957  
    2020 
    2121// initialize the storage 
    22 $database = new sfPDODatabase(); 
    23 $database->initialize(array('dsn' => 'sqlite::memory:')); 
     22$database = new sfPDODatabase(array('dsn' => 'sqlite::memory:')); 
    2423$connection = $database->getConnection(); 
    2524$connection->exec('CREATE TABLE session (sess_id, sess_data, sess_time)'); 
     
    2827$session_id = "1"; 
    2928 
    30 $storage = sfStorage::newInstance('sfPDOSessionStorage'); 
    31 $storage->initialize(array('db_table' => 'session', 'session_id' => $session_id, 'database' => $database)); 
     29$storage = new sfPDOSessionStorage(array('db_table' => 'session', 'session_id' => $session_id, 'database' => $database)); 
    3230$t->ok($storage instanceof sfStorage, 'sfPDOSessionStorage is an instance of sfStorage'); 
    3331$t->ok($storage instanceof sfDatabaseSessionStorage, 'sfPDOSessionStorage is an instance of sfDatabaseSessionStorage'); 
  • trunk/test/unit/storage/sfStorageTest.php

    r4890 r4957  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(17, new lime_output_color()); 
     13$t = new lime_test(14, new lime_output_color()); 
    1414 
    1515class myStorage extends sfStorage 
     
    2525} 
    2626 
    27 // ::newInstance() 
    28 $t->diag('::newInstance()'); 
    29 $t->isa_ok(sfStorage::newInstance('myStorage'), 'myStorage', '::newInstance() takes a storage class as its first parameter'); 
    30 $t->isa_ok(sfStorage::newInstance('myStorage'), 'myStorage', '::newInstance() returns an instance of myStorage'); 
    31  
    32 try 
    33 { 
    34   sfStorage::newInstance('fakeStorage'); 
    35   $t->fail('::newInstance() throws a sfFactoryException if the class does not extends sfStorage'); 
    36 } 
    37 catch (sfFactoryException $e) 
    38 { 
    39   $t->pass('::newInstance() throws a sfFactoryException if the class does not extends sfStorage'); 
    40 } 
    41  
    4227// ->initialize() 
    4328$t->diag('->initialize()'); 
    44 $storage = sfStorage::newInstance('myStorage'); 
    45 $storage->initialize(array('foo' => 'bar')); 
     29$storage = new myStorage(array('foo' => 'bar')); 
    4630$t->is($storage->getParameter('foo'), 'bar', '->initialize() takes an array of parameters as its second argument'); 
    4731 
    4832$storage = new myStorage(); 
    49 $storage->initialize(); 
    5033 
    5134// parameter holder proxy 
  • trunk/test/unit/task/cache/sfCacheClearTaskTest.php

    r4743 r4957  
    1313$t = new lime_test(2, new lime_output_color()); 
    1414 
    15 sfTask::newInstance('sfGenerateProjectTask')->run(array('test')); 
    16 sfTask::newInstance('sfGenerateAppTask')->run(array('frontend')); 
     15$task = new sfGenerateProjectTask(); 
     16$task->run(array('test')); 
     17$task = new sfGenerateAppTask(); 
     18$task->run(array('frontend')); 
    1719 
    1820sfCore::initDirectoryLayout(sfConfig::get('sf_root_dir'), 'frontend', 'dev'); 
     
    2527$t->ok(file_exists($file), 'The test file is in the cache'); 
    2628 
    27 sfTask::newInstance('sfCacheClearTask')->run(); 
     29$task = new sfCacheClearTask(); 
     30$task->run(); 
    2831 
    2932$t->ok(!file_exists($file), 'The test file is removed by the cache:clear task'); 
  • trunk/test/unit/user/sfBasicSecurityUserTest.php

    r4951 r4957  
    1414 
    1515$dispatcher = new sfEventDispatcher(); 
    16 $storage = sfStorage::newInstance('sfSessionTestStorage'); 
    17 $storage->initialize(array('session_path' => sfConfig::get('sf_test_cache_dir').'/sessions')); 
     16$storage = new sfSessionTestStorage(array('session_path' => sfConfig::get('sf_test_cache_dir').'/sessions')); 
    1817 
    19 $user = new sfBasicSecurityUser(); 
    20 $user->initialize($dispatcher, $storage); 
     18$user = new sfBasicSecurityUser($dispatcher, $storage); 
    2119 
    2220// ->initialize() 
     
    2523/* 
    2624sfConfig::set('sf_timeout', 0); 
    27 $user = new sfBasicSecurityUser(); 
    28 $user->initialize($context); 
     25$user = new sfBasicSecurityUser($context); 
    2926$t->is($user->isTimedOut(), true, '->initialize() times out the user if no request made for a long time'); 
    3027*/ 
     
    4643// ->setTimedOut() ->getTimedOut() 
    4744sfConfig::set('sf_timeout', 86400); 
    48 $user = new sfBasicSecurityUser(); 
    49 $user->initialize($dispatcher, $storage); 
     45$user = new sfBasicSecurityUser($dispatcher, $storage); 
    5046$t->diag('->setTimedOut() ->isTimedOut()'); 
    5147$t->is($user->isTimedOut(), false, '->isTimedOut() returns false if the session is not timed out'); 
  • trunk/test/unit/user/sfUserTest.php

    r4951 r4957  
    1717 
    1818$dispatcher = new sfEventDispatcher(); 
    19 $storage = sfStorage::newInstance('sfSessionTestStorage'); 
    20 $storage->initialize(array('session_path' => sfConfig::get('sf_test_cache_dir').'/sessions')); 
     19$storage = new sfSessionTestStorage(array('session_path' => sfConfig::get('sf_test_cache_dir').'/sessions')); 
    2120 
    22 $user = new sfUser(); 
    23 $user->initialize($dispatcher, $storage); 
     21$user = new sfUser($dispatcher, $storage); 
    2422 
    2523// ->initialize() 
     
    3836$t->is($user->getCulture(), 'de', '->initialize() reads the culture from the session data if available'); 
    3937 
    40 $userBis = new sfUser(); 
    41 $userBis->initialize($dispatcher, $storage); 
     38$userBis = new sfUser($dispatcher, $storage); 
    4239$t->is($userBis->getCulture(), 'de', '->initialize() serializes the culture to the session data'); 
    4340 
     
    5552user_flush($dispatcher, $user, $storage, array('use_flash' => true)); 
    5653 
    57 $userBis = new sfUser(); 
    58 $userBis->initialize($dispatcher, $storage, array('use_flash' => true)); 
     54$userBis = new sfUser($dispatcher, $storage, array('use_flash' => true)); 
    5955$t->is($userBis->getFlash('foo'), 'bar', '->getFlash() returns a flash previously set'); 
    6056$t->is($userBis->hasFlash('foo'), true, '->hasFlash() returns true if the flash variable exists'); 
    6157user_flush($dispatcher, $user, $storage, array('use_flash' => true)); 
    6258 
    63 $userBis = new sfUser(); 
    64 $userBis->initialize($dispatcher, $storage, array('use_flash' => true)); 
     59$userBis = new sfUser($dispatcher, $storage, array('use_flash' => true)); 
    6560$t->is($userBis->getFlash('foo'), null, 'Flashes are automatically removed after the next request'); 
    6661$t->is($userBis->hasFlash('foo'), false, '->hasFlash() returns true if the flash variable exists'); 
  • trunk/test/unit/validator/sfCallbackValidatorTest.php

    r4440 r4957  
    1515 
    1616$context = sfContext::getInstance(); 
    17 $v = new sfCallbackValidator(); 
    1817 
    1918// ->initialize() 
     
    2221try 
    2322{ 
    24   $v->initialize($context); 
     23  $v = new sfCallbackValidator($context); 
    2524  $t->fail('->initialize() takes a mandatory "callback" parameter'); 
    2625} 
     
    3231try 
    3332{ 
    34   $v->initialize($context, array('callback' => 'arandomstring')); 
     33  $v = new sfCallbackValidator($context, array('callback' => 'arandomstring')); 
    3534  $t->fail('->initialize() takes a callable as a "callback" parameter'); 
    3635} 
     
    5857} 
    5958 
    60 $t->ok($v->initialize($context, array('callback' => 'callbackValidator')), '->initialize() can take a function as a callback'); 
    61 $t->ok($v->initialize($context, array('callback' => array(new callbackClassValidator(), 'callbackValidator'))), '->initialize() can take an instance method as a callback'); 
    62 $t->ok($v->initialize($context, array('callback' => array('callbackClassValidator', 'staticCallbackValidator'))), '->initialize() can take a static method as a callback'); 
     59$t->ok(new sfCallbackValidator($context, array('callback' => 'callbackValidator')), '->initialize() can take a function as a callback'); 
     60$t->ok(new sfCallbackValidator($context, array('callback' => array(new callbackClassValidator(), 'callbackValidator'))), '->initialize() can take an instance method as a callback'); 
     61$t->ok(new sfCallbackValidator($context, array('callback' => array('callbackClassValidator', 'staticCallbackValidator'))), '->initialize() can take a static method as a callback'); 
    6362 
    64 $t->ok($v->initialize($context, array('callback' => 'callbackValidator', 'invalid_error' => 'my error')), '->initialize() takes a custom message "invalid_error"'); 
     63$t->ok($v = new sfCallbackValidator($context, array('callback' => 'callbackValidator', 'invalid_error' => 'my error')), '->initialize() takes a custom message "invalid_error"'); 
    6564$value = false; 
    6665$error = null; 
     
    7069// ->execute() 
    7170$t->diag('->execute()'); 
    72 $v->initialize($context, array('callback' => 'callbackValidator')); 
     71$c = new sfCallbackValidator($context, array('callback' => 'callbackValidator')); 
    7372 
    7473$value = true; 
  • trunk/test/unit/validator/sfCompareValidatorTest.php

    r4440 r4957  
    2828$request = $context->request; 
    2929 
    30 $v = new sfCompareValidator(); 
    3130$h = new sfValidatorTestHelper($context, $t); 
    3231 
     
    3433try 
    3534{ 
    36   $v->initialize($context); 
     35  $v = new sfCompareValidator($context); 
    3736  $t->fail('->initialize() takes a required "check" parameter'); 
    3837} 
     
    4443try 
    4544{ 
    46   $v->initialize($context, array('check' => 'value', 'operator' => 'N')); 
     45  $v = new sfCompareValidator($context, array('check' => 'value', 'operator' => 'N')); 
    4746  $t->fail('->initialize() takes an "operator" parameter in (>, >=, <, <=, ==, !=)'); 
    4847} 
     
    5453// == operator (default operator) 
    5554$t->diag('->execute() - == operator (default operator)'); 
     55$v = new sfCompareValidator($context, array('check' => 'value')); 
    5656$request->parameters = array('value2' => 'azerty'); 
    5757$options = array('check' => 'value2'); 
  • trunk/test/unit/validator/sfRegexValidatorTest.php

    r4440 r4957  
    1515 
    1616$context = sfContext::getInstance(); 
    17 $v = new sfRegexValidator(); 
    1817 
    1918// ->initialize() 
     
    2221try 
    2322{ 
    24   $v->initialize($context); 
     23  $v = new sfRegexValidator($context); 
    2524  $t->fail('->initialize() takes a mandatory "pattern" parameter'); 
    2625} 
     
    3029} 
    3130 
    32 $t->ok($v->initialize($context, array('pattern' => '/\d+/')), '->initialize() takes a "pattern" as a parameter'); 
     31$t->ok(new sfRegexValidator($context, array('pattern' => '/\d+/')), '->initialize() takes a "pattern" as a parameter'); 
    3332 
    34 $v->initialize($context, array('pattern' => '/\d+/', 'match_error' => 'my error message')); 
     33$v = new sfRegexValidator($context, array('pattern' => '/\d+/', 'match_error' => 'my error message')); 
    3534$value = 'a string'; 
    3635$error = null; 
  • trunk/test/unit/view/sfViewCacheManagerTest.php

    r4579 r4957  
    1212require_once($_test_dir.'/unit/sfContextMock.class.php'); 
    1313 
    14 $t = new lime_test(12, new lime_output_color()); 
     14$t = new lime_test(11, new lime_output_color()); 
    1515 
    1616class myController extends sfWebController 
     
    9292// ->initialize() 
    9393$t->diag('->initialize()'); 
    94 $m = new sfViewCacheManager(); 
    95 $t->is($m->getContext(), null, '->initialize() takes a sfContext object as its first argument'); 
    96  
    97 // ->getContext() 
    98 $t->diag('->getContext()'); 
    99 $m->initialize($context, new myCache()); 
    100 $t->is($m->getContext(), $context, '->getContext() returns the current context'); 
     94$m = new sfViewCacheManager($context, $cache = new myCache()); 
     95$t->is($m->getCache(), $cache, '->initialize() takes a sfCache object as its second argument'); 
    10196 
    10297// ->generateNamespace() 
     
    149144{ 
    150145  myCache::clear(); 
    151   $m = new sfViewCacheManager(); 
    152   $m->initialize($context, new myCache()); 
     146  $m = new sfViewCacheManager($context, new myCache()); 
    153147 
    154148  return $m; 
  • trunk/test/unit/view/sfViewTest.php

    r4951 r4957  
    3737 
    3838$context = sfContext::getInstance(); 
    39 $view = new myView(); 
    40 $view->initialize($context, '', '', ''); 
     39$view = new myView($context, '', '', ''); 
    4140 
    4241// ->isDecorator() ->setDecorator() 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.