Changeset 4957
- Timestamp:
- 09/03/07 10:58:56 (2 years ago)
- Files:
-
- trunk/data/skeleton/batch/default.php (modified) (1 diff)
- trunk/lib/action/sfAction.class.php (modified) (1 diff)
- trunk/lib/action/sfComponent.class.php (modified) (6 diffs)
- trunk/lib/cache/sfCache.class.php (modified) (1 diff)
- trunk/lib/command/sfSymfonyCommandApplication.class.php (modified) (1 diff)
- trunk/lib/config/sfConfigCache.class.php (modified) (2 diffs)
- trunk/lib/config/sfConfigHandler.class.php (modified) (2 diffs)
- trunk/lib/config/sfFactoryConfigHandler.class.php (modified) (9 diffs)
- trunk/lib/config/sfFilterConfigHandler.class.php (modified) (2 diffs)
- trunk/lib/config/sfValidatorConfigHandler.class.php (modified) (1 diff)
- trunk/lib/controller/sfController.class.php (modified) (5 diffs)
- trunk/lib/database/sfDatabase.class.php (modified) (2 diffs)
- trunk/lib/database/sfDatabaseManager.class.php (modified) (2 diffs)
- trunk/lib/filter/sfBasicSecurityFilter.class.php (modified) (1 diff)
- trunk/lib/filter/sfExecutionFilter.class.php (modified) (3 diffs)
- trunk/lib/filter/sfFilter.class.php (modified) (2 diffs)
- trunk/lib/filter/sfSecurityFilter.class.php (deleted)
- trunk/lib/generator/sfGenerator.class.php (modified) (1 diff)
- trunk/lib/generator/sfGeneratorManager.class.php (modified) (2 diffs)
- trunk/lib/helper/PartialHelper.php (modified) (3 diffs)
- trunk/lib/i18n/extract/sfI18nExtract.class.php (modified) (1 diff)
- trunk/lib/i18n/sfI18N.class.php (modified) (1 diff)
- trunk/lib/log/sfLogger.class.php (modified) (1 diff)
- trunk/lib/request/sfRequest.class.php (modified) (2 diffs)
- trunk/lib/response/sfResponse.class.php (modified) (2 diffs)
- trunk/lib/routing/sfPatternRouting.class.php (modified) (1 diff)
- trunk/lib/routing/sfRouting.class.php (modified) (1 diff)
- trunk/lib/storage/sfStorage.class.php (modified) (2 diffs)
- trunk/lib/task/propel/sfPropelDataDumpTask.class.php (modified) (1 diff)
- trunk/lib/task/propel/sfPropelDataLoadTask.class.php (modified) (1 diff)
- trunk/lib/task/propel/sfPropelGenerateCrudTask.class.php (modified) (1 diff)
- trunk/lib/task/sfTask.class.php (modified) (1 diff)
- trunk/lib/user/sfUser.class.php (modified) (3 diffs)
- trunk/lib/util/sfContext.class.php (modified) (1 diff)
- trunk/lib/validator/sfValidator.class.php (modified) (2 diffs)
- trunk/lib/validator/sfValidatorManager.class.php (modified) (2 diffs)
- trunk/lib/view/sfView.class.php (modified) (2 diffs)
- trunk/lib/view/sfViewCacheManager.class.php (modified) (1 diff)
- trunk/test/unit/action/sfComponentTest.php (modified) (1 diff)
- trunk/test/unit/cache/sfAPCCacheTest.php (modified) (1 diff)
- trunk/test/unit/cache/sfCacheTest.php (modified) (1 diff)
- trunk/test/unit/cache/sfEAcceleratorCacheTest.php (modified) (1 diff)
- trunk/test/unit/cache/sfFileCacheTest.php (modified) (2 diffs)
- trunk/test/unit/cache/sfMemcacheCacheTest.php (modified) (1 diff)
- trunk/test/unit/cache/sfNoCacheTest.php (modified) (1 diff)
- trunk/test/unit/cache/sfSQLiteCacheTest.php (modified) (3 diffs)
- trunk/test/unit/cache/sfXCacheCacheTest.php (modified) (1 diff)
- trunk/test/unit/config/fixtures/sfFilterConfigHandler/result.php (modified) (3 diffs)
- trunk/test/unit/controller/sfControllerTest.php (modified) (1 diff)
- trunk/test/unit/controller/sfWebControllerTest.php (modified) (1 diff)
- trunk/test/unit/generator/sfGeneratorTest.php (modified) (1 diff)
- trunk/test/unit/log/sfAggregateLoggerTest.php (modified) (2 diffs)
- trunk/test/unit/log/sfConsoleLoggerTest.php (modified) (1 diff)
- trunk/test/unit/log/sfFileLoggerTest.php (modified) (2 diffs)
- trunk/test/unit/log/sfLoggerTest.php (modified) (2 diffs)
- trunk/test/unit/request/sfRequestTest.php (modified) (2 diffs)
- trunk/test/unit/request/sfWebRequestTest.php (modified) (1 diff)
- trunk/test/unit/response/sfResponseTest.php (modified) (2 diffs)
- trunk/test/unit/response/sfWebResponseTest.php (modified) (5 diffs)
- trunk/test/unit/routing/sfNoRoutingTest.php (modified) (1 diff)
- trunk/test/unit/routing/sfPathInfoRoutingTest.php (modified) (1 diff)
- trunk/test/unit/routing/sfPatternRoutingTest.php (modified) (1 diff)
- trunk/test/unit/sfContextMock.class.php (modified) (2 diffs)
- trunk/test/unit/storage/sfNoStorageTest.php (modified) (1 diff)
- trunk/test/unit/storage/sfPDOSessionStorageTest.php (modified) (2 diffs)
- trunk/test/unit/storage/sfStorageTest.php (modified) (2 diffs)
- trunk/test/unit/task/cache/sfCacheClearTaskTest.php (modified) (2 diffs)
- trunk/test/unit/user/sfBasicSecurityUserTest.php (modified) (3 diffs)
- trunk/test/unit/user/sfUserTest.php (modified) (3 diffs)
- trunk/test/unit/validator/sfCallbackValidatorTest.php (modified) (5 diffs)
- trunk/test/unit/validator/sfCompareValidatorTest.php (modified) (4 diffs)
- trunk/test/unit/validator/sfRegexValidatorTest.php (modified) (3 diffs)
- trunk/test/unit/view/sfViewCacheManagerTest.php (modified) (3 diffs)
- trunk/test/unit/view/sfViewTest.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/data/skeleton/batch/default.php
r1686 r4957 20 20 // initialize database manager 21 21 //$databaseManager = new sfDatabaseManager(); 22 //$databaseManager->initialize();23 22 24 23 // batch process here trunk/lib/action/sfAction.class.php
r4951 r4957 31 31 * @return bool true, if initialization completes successfully, otherwise false 32 32 */ 33 public function initialize($context )34 { 35 parent::initialize($context );33 public function initialize($context, $moduleName, $actionName) 34 { 35 parent::initialize($context, $moduleName, $actionName); 36 36 37 37 // include security configuration 38 38 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;41 39 } 42 40 trunk/lib/action/sfComponent.class.php
r4951 r4957 20 20 { 21 21 protected 22 $moduleName = '', 23 $actionName = '', 22 24 $context = null, 23 25 $dispatcher = null, … … 28 30 29 31 /** 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 /** 30 42 * Initializes this component. 31 43 * … … 34 46 * @return boolean true, if initialization completes successfully, otherwise false 35 47 */ 36 public function initialize($context) 37 { 48 public function initialize($context, $moduleName, $actionName) 49 { 50 $this->moduleName = $moduleName; 51 $this->actionName = $actionName; 38 52 $this->context = $context; 39 53 $this->dispatcher = $context->getEventDispatcher(); … … 42 56 $this->response = $context->getResponse(); 43 57 $this->requestParameterHolder = $this->request->getParameterHolder(); 44 45 return true;46 58 } 47 59 … … 68 80 public function getModuleName() 69 81 { 70 return $this-> context->getModuleName();82 return $this->moduleName; 71 83 } 72 84 … … 78 90 public function getActionName() 79 91 { 80 return $this-> context->getActionName();92 return $this->actionName; 81 93 } 82 94 trunk/lib/cache/sfCache.class.php
r4586 r4957 27 27 28 28 /** 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); 47 36 } 48 37 trunk/lib/command/sfSymfonyCommandApplication.class.php
r4951 r4957 85 85 protected function initializeLogger() 86 86 { 87 $logger = new sfCommandLogger(); 88 $logger->initialize(new sfEventDispatcher(), array('output' => new sfConsoleColorizer())); 87 $logger = new sfCommandLogger(new sfEventDispatcher(), array('output' => new sfConsoleColorizer())); 89 88 $this->setLogger($logger); 90 89 } trunk/lib/config/sfConfigCache.class.php
r4853 r4957 271 271 // manually create our config_handlers.yml handler 272 272 $this->handlers['config_handlers.yml'] = new sfRootConfigHandler(); 273 $this->handlers['config_handlers.yml']->initialize();274 273 275 274 // application configuration handlers … … 354 353 public function registerConfigHandler($handler, $class, $params = array()) 355 354 { 356 $this->userHandlers[$handler] = new $class(); 357 $this->userHandlers[$handler]->initialize($params); 355 $this->userHandlers[$handler] = new $class($params); 358 356 } 359 357 trunk/lib/config/sfConfigHandler.class.php
r3203 r4957 27 27 28 28 /** 29 * Executes this configuration handler29 * Class constructor. 30 30 * 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() 37 32 */ 38 abstract public function execute($configFiles); 33 public function __construct($parameters = null) 34 { 35 $this->initialize($parameters); 36 } 39 37 40 38 /** … … 52 50 $this->parameterHolder->add($parameters); 53 51 } 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); 54 64 55 65 /** trunk/lib/config/sfFactoryConfigHandler.class.php
r4951 r4957 45 45 // init our data and includes arrays 46 46 $includes = array(); 47 $inits = array();48 47 $instances = array(); 49 48 … … 99 98 { 100 99 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); 106 101 break; 107 102 108 103 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)); 114 105 break; 115 106 116 107 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"); 123 111 break; 124 112 125 113 case 'storage': 126 // append instance creation127 $instances[] = sprintf(" \$this->factories['storage'] = sfStorage::newInstance(sfConfig::get('sf_factory_storage', '%s'));", $class);128 129 // append instance initialization130 114 $defaultParameters = array(); 131 115 $defaultParameters[] = sprintf("'session_id' => \$this->getRequest()->getParameter('%s'),", $parameters['session_name']); … … 134 118 $defaultParameters[] = sprintf("'database' => \$this->getDatabaseManager()->getDatabase('%s'),", isset($parameters['database']) ? $parameters['database'] : 'default'); 135 119 } 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)); 137 122 break; 138 123 139 124 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)); 145 126 break; 146 127 147 128 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". 154 133 " }\n". 155 134 " else\n". … … 161 140 162 141 case 'i18n': 163 // append i18n instance initialization164 142 if (isset($parameters['cache'])) 165 143 { 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)); 167 145 unset($parameters['cache']); 168 146 } … … 171 149 $cache = " \$cache = null;\n"; 172 150 } 173 $in its[] = sprintf("\n if (sfConfig::get('sf_i18n'))\n {\n".151 $instances[] = sprintf("\n if (sfConfig::get('sf_i18n'))\n {\n". 174 152 " \$class = sfConfig::get('sf_factory_i18n', '%s');\n". 175 " \$this->factories['i18n'] = new \$class();\n".176 153 "%s". 177 " \$this->factories['i18n'] ->initialize(\$this, \$cache);\n".154 " \$this->factories['i18n'] = new \$class(\$this, \$cache);\n". 178 155 " }\n" 179 156 , $class, $cache … … 182 159 183 160 case 'routing': 184 // append instance creation185 $instances[] = sprintf(" \$this->factories['routing'] = sfRouting::newInstance(sfConfig::get('sf_factory_routing', '%s'));", $class);186 187 // append instance initialization188 $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 } 189 166 break; 190 167 191 168 case 'logger': 192 // append instance creation and initialization193 169 $loggers = ''; 194 170 if (isset($parameters['loggers'])) … … 217 193 { 218 194 // 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", 220 196 $keys['class'], 221 197 isset($keys['param']) ? var_export($keys['param'], true) : '' … … 228 204 229 205 $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". 232 207 " %s" 233 208 , $class, var_export($parameters, true), $loggers); … … 239 214 $retval = sprintf("<?php\n". 240 215 "// auto-generated by sfFactoryConfigHandler\n". 241 "// date: %s\n%s\n%s\n %s\n",216 "// date: %s\n%s\n%s\n", 242 217 date('Y/m/d H:i:s'), implode("\n", $includes), 243 implode("\n", $instances) , implode("\n", $inits));218 implode("\n", $instances)); 244 219 245 220 return $retval; trunk/lib/config/sfFilterConfigHandler.class.php
r4597 r4957 164 164 { 165 165 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". 168 167 "\$filterChain->register(\$filter);", 169 168 $category, $class, $parameters); … … 186 185 if (\$actionInstance->isSecure()) 187 186 { 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 }192 187 {$this->addFilter($category, $class, $parameters)} 193 188 } trunk/lib/config/sfValidatorConfigHandler.class.php
r4597 r4957 178 178 $validator =& $validators[$valName]; 179 179 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']); 183 182 184 183 // mark this validator as created for this request method trunk/lib/controller/sfController.class.php
r4951 r4957 29 29 30 30 /** 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 /** 31 60 * Indicates whether or not a module has a specific component. 32 61 * … … 206 235 } 207 236 237 // module enabled? 208 238 if (sfConfig::get('mod_'.strtolower($moduleName).'_enabled')) 209 239 { 210 // module is enabled211 212 240 // check for a module config.php 213 241 $moduleConfig = sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/config.php'; … … 217 245 } 218 246 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(); 237 256 } 238 257 else 239 258 { 240 // module is disabled241 259 $moduleName = sfConfig::get('sf_module_disabled_module'); 242 260 $actionName = sfConfig::get('sf_module_disabled_action'); … … 307 325 } 308 326 309 return new $class( );327 return new $class($this->context, $moduleName, $controllerName); 310 328 } 311 329 … … 363 381 { 364 382 // 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); 417 388 } 418 389 trunk/lib/database/sfDatabase.class.php
r4890 r4957 26 26 $connection = null, 27 27 $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 } 28 53 29 54 /** … … 69 94 70 95 return $this->resource; 71 }72 73 /**74 * Initializes this sfDatabase object.75 *76 * @param array An associative array of initialization parameters77 *78 * @return bool true, if initialization completes successfully, otherwise false79 *80 * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfDatabase object81 */82 public function initialize($parameters = array())83 {84 $this->parameterHolder = new sfParameterHolder();85 $this->parameterHolder->add($parameters);86 96 } 87 97 trunk/lib/database/sfDatabaseManager.class.php
r4597 r4957 27 27 28 28 /** 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 /** 29 52 * Retrieves the database connection associated with this sfDatabase implementation. 30 53 * … … 47 70 48 71 /** 49 * Initializes this sfDatabaseManager object50 *51 * @return bool true, if initialization completes successfully, otherwise false52 *53 * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfDatabaseManager object54 */55 public function initialize()56 {57 // load database configuration58 require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/databases.yml'));59 }60 61 /**62 72 * Executes the shutdown procedure 63 73 * trunk/lib/filter/sfBasicSecurityFilter.class.php
r4593 r4957 21 21 * @version SVN: $Id$ 22 22 */ 23 class sfBasicSecurityFilter extends sf SecurityFilter23 class sfBasicSecurityFilter extends sfFilter 24 24 { 25 25 /** trunk/lib/filter/sfExecutionFilter.class.php
r4951 r4957 116 116 { 117 117 // create validator manager 118 $validatorManager = new sfValidatorManager(); 119 $validatorManager->initialize($this->context); 118 $validatorManager = new sfValidatorManager($this->context); 120 119 121 120 require($validateFile); … … 227 226 // get the view instance 228 227 $view = $controller->getView($moduleName, $actionName, $viewName); 229 $view->initialize($this->context, $moduleName, $actionName, $viewName);230 228 231 229 // execute the view … … 265 263 { 266 264 // 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()); 269 266 $filterChain->register($fillInFormFilter); 270 267 } trunk/lib/filter/sfFilter.class.php
r3525 r4957 29 29 30 30 /** 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 /** 31 61 * Returns true if this is the first call to the sfFilter instance. 32 62 * … … 56 86 { 57 87 return $this->context; 58 }59 60 /**61 * Initializes this Filter.62 *63 * @param sfContext The current application context64 * @param array An associative array of initialization parameters65 *66 * @return boolean true, if initialization completes successfully, otherwise false67 *68 * @throws <b>sfInitializationException</b> If an error occurs while initializing this Filter69 */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;78 88 } 79 89 trunk/lib/generator/sfGenerator.class.php
r4951 r4957 27 27 28 28 /** 29 * Class constructor. 30 * 31 * @see initialize() 32 */ 33 public function __construct(sfGeneratorManager $generatorManager) 34 { 35 $this->initialize($generatorManager); 36 } 37 38 /** 29 39 * Initializes the current sfGenerator instance. 30 40 * trunk/lib/generator/sfGeneratorManager.class.php
r4578 r4957 19 19 class sfGeneratorManager 20 20 { 21 /** 22 * Class constructor. 23 * 24 * @see initialize() 25 */ 26 public function __construct() 27 { 28 $this->initialize(); 29 } 30 21 31 /** 22 32 * Initializes the sfGeneratorManager instance. … … 50 60 public function generate($generator_class, $param) 51 61 { 52 $generator = new $generator_class(); 53 $generator->initialize($this); 62 $generator = new $generator_class($this); 54 63 55 64 return $generator->generate($param); trunk/lib/helper/PartialHelper.php
r4951 r4957 132 132 $componentInstance = $controller->getComponent($moduleName, $componentName); 133 133 134 // initialize the action135 if (!$componentInstance->initialize($context))136 {137 // component failed to initialize138 throw new sfInitializationException(sprintf('Component initialization failed for module "%s", component "%s".', $moduleName, $componentName));139 }140 141 134 // load component's module config file 142 135 require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/module.yml')); … … 178 171 { 179 172 // render 180 $view = new sfPartialView(); 181 $view->initialize($context, $moduleName, $actionName, ''); 182 173 $view = new sfPartialView($context, $moduleName, $actionName, ''); 183 174 $view->getAttributeHolder()->add($componentInstance->getVarHolder()->getAll()); 184 175 … … 258 249 } 259 250 260 $view = new sfPartialView(); 261 $view->initialize($context, $moduleName, $actionName, ''); 251 $view = new sfPartialView($context, $moduleName, $actionName, ''); 262 252 $view->getAttributeHolder()->add($vars); 263 253 trunk/lib/i18n/extract/sfI18nExtract.class.php
r4576 r4957 26 26 27 27 /** 28 * Class constructor. 29 * 30 * @see initialize() 31 */ 32 public function __construct($culture, $parameters = array()) 33 { 34 $this->initialize($culture, $parameters); 35 } 36 37 /** 28 38 * Initializes the current extract object. 29 39 * trunk/lib/i18n/sfI18N.class.php
r4951 r4957 27 27 28 28 /** 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 /** 29 39 * Initializes this class. 30 40 * trunk/lib/log/sfLogger.class.php
r4951 r4957 42 42 43 43 /** 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); 67 51 } 68 52 trunk/lib/request/sfRequest.class.php
r4951 r4957 68 68 69 69 /** 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 /** 70 80 * Initializes this sfRequest. 71 81 * … … 179 189 { 180 190 return count($this->errors) > 0; 181 }182 183 /**184 * Retrieves a new sfRequest implementation instance.185 *186 * @param string A sfRequest implementation name187 *188 * @return sfRequest A sfRequest implementation instance189 *190 * @throws <b>sfFactoryException</b> If a request implementation instance cannot be created191 */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;202 191 } 203 192 trunk/lib/response/sfResponse.class.php
r4951 r4957 26 26 27 27 /** 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 /** 28 38 * Initializes this sfResponse. 29 39 * … … 41 51 $this->parameterHolder = new sfParameterHolder(); 42 52 $this->parameterHolder->add($parameters); 43 }44 45 /**46 * Retrieves a new sfResponse implementation instance.47 *48 * @param string A sfResponse implementation name49 *50 * @return sfResponse A sfResponse implementation instance51 *52 * @throws <b>sfFactoryException</b> If a response implementation instance cannot be created53 */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;64 53 } 65 54 trunk/lib/routing/sfPatternRouting.class.php
r4951 r4957 45 45 46 46 $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); 54 57 } 55 58 } trunk/lib/routing/sfRouting.class.php
r4951 r4957 25 25 26 26 /** 27 * Retrieves a new sfRouting implementation instance.27 * Class constructor. 28 28 * 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() 34 30 */ 35 public static function newInstance($class)31 public function __construct(sfEventDispatcher $dispatcher, $parameters = array()) 36 32 { 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); 45 34 } 46 35 trunk/lib/storage/sfStorage.class.php
r4890 r4957 25 25 26 26 /** 27 * Class constructor. 28 * 29 * @see initialize() 30 */ 31 public function __construct($parameters = array()) 32 { 33 $this->initialize($parameters); 34 } 35 36 /** 27 37 * Initializes this Storage instance. 28 38 * … … 37 47 $this->parameterHolder = new sfParameterHolder(); 38 48 $this->getParameterHolder()->add($parameters); 39 }40 41 /**42 * Retrieves a new sfStorage implementation instance.43 *44 * @param string A sfStorage implementation name45 *46 * @return sfStorage A sfStorage implementation instance47 *48 * @throws <b>sfFactoryException</b> If a storage implementation instance cannot be created49 */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;60 49 } 61 50 trunk/lib/task/propel/sfPropelDataDumpTask.class.php
r4743 r4957 66 66 67 67 $databaseManager = new sfDatabaseManager(); 68 $databaseManager->initialize();69 68 70 69 if (!sfToolkit::isPathAbsolute($filename)) trunk/lib/task/propel/sfPropelDataLoadTask.class.php
r4942 r4957 91 91 92 92 $databaseManager = new sfDatabaseManager(); 93 $databaseManager->initialize();94 93 95 94 $data = new sfPropelData(); trunk/lib/task/propel/sfPropelGenerateCrudTask.class.php
r4743 r4957 66 66 sfConfig::set('sf_module_cache_dir', $tmpDir); 67 67 $generatorManager = new sfGeneratorManager(); 68 $generatorManager->initialize();69 68 $generatorManager->generate('sfPropelCrudGenerator', array('model_class' => $arguments['model'], 'moduleName' => $arguments['module'], 'theme' => $options['theme'])); 70 69 trunk/lib/task/sfTask.class.php
r4845 r4957 34 34 * @param sfCommandApplication A sfCommandApplication object 35 35 */ 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) 37 52 { 38 53 $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); 65 55 } 66 56 trunk/lib/user/sfUser.class.php
r4951 r4957 40 40 41 41 /** 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 /** 42 52 * Initializes this sfUser. 43 53 * … … 75 85 // - use the default culture set in i18n.yml 76 86 $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'))); 80 88 81 89 // flag current flash to be removed at shutdown … … 95 103 96 104 /** 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. 119 106 * 120 107 * @param string culture trunk/lib/util/sfContext.class.php
r4951 r4957 42 42 // setup our database connections 43 43 $this->factories['databaseManager'] = new sfDatabaseManager(); 44 $this->factories['databaseManager']->initialize();45 44 } 46 45 trunk/lib/validator/sfValidator.class.php
r3250 r4957 26 26 27 27 /** 28 * Executes this validator.28 * Class constructor. 29 29 * 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() 34 31 */ 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()) 43 33 { 44 return $this->context;34 $this->initialize($context, $parameters); 45 35 } 46 36 … … 61 51 62 52 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; 63 73 } 64 74 trunk/lib/validator/sfValidatorManager.class.php
r4951 r4957 28 28 29 29 /** 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 /** 30 50 * Clears this validator manager so it can be reused. 31 51 */ … … 102 122 103 123 /** 104 * Initializes this validator manager.105 *106 * @param sfContext A sfContext instance107 */108 public function initialize($context)109 {110 $this->request = $context->getRequest();111 }112 113 /**114 124 * Registers a file or parameter. 115 125 * trunk/lib/view/sfView.class.php
r4951 r4957 86 86 87 87 /** 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); 144 95 } 145 96 … … 186 137 187 138 /** 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 /** 188 198 * Retrieves attributes for the current view. 189 199 * trunk/lib/view/sfViewCacheManager.class.php
r4951 r4957 33 33 34 34 /** 35 * Class constructor. 36 * 37 * @see initialize() 38 */ 39 public function __construct($context, sfCache $cache) 40 { 41 $this->initialize($context, $cache); 42 } 43 44 /** 35 45 * Initializes the cache manager. 36 46 * trunk/test/unit/action/sfComponentTest.php
r4951 r4957 26 26 // ->initialize() 27 27 $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'); 30 30 $component->initialize($context); 31 31 $t->is($component->getContext(), $context, '->initialize() takes a sfContext object as its first argument'); trunk/test/unit/cache/sfAPCCacheTest.php
r4579 r4957 33 33 // ->initialize() 34 34 $t->diag('->initialize()'); 35 $cache = sfCache::newInstance('sfAPCCache');35 $cache = new sfAPCCache(); 36 36 $cache->initialize(); 37 37 trunk/test/unit/cache/sfCacheTest.php
r4579 r4957 27 27 } 28 28 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()); 45 30 46 31 // ->initialize() 47 32 $t->diag('->initialize()'); 48 $cache = sfCache::newInstance('myCache');33 $cache = new myCache(); 49 34 $cache->initialize(array('foo' => 'bar')); 50 35 $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 27 27 // ->initialize() 28 28 $t->diag('->initialize()'); 29 $cache = sfCache::newInstance('sfEAcceleratorCache');29 $cache = new sfEAcceleratorCache(); 30 30 $cache->initialize(); 31 31 trunk/test/unit/cache/sfFileCacheTest.php
r4579 r4957 22 22 // ->initialize() 23 23 $t->diag('->initialize()'); 24 $cache = sfCache::newInstance('sfFileCache');25 24 try 26 25 { 27 $cache ->initialize();26 $cache = new sfFileCache(); 28 27 $t->fail('->initialize() throws an sfInitializationException exception if you don\'t pass a "cacheDir" parameter'); 29 28 } … … 33 32 } 34 33 35 $cache = sfCache::newInstance('sfFileCache'); 36 $cache->initialize(array('cacheDir' => $temp)); 34 $cache = new sfFileCache(array('cacheDir' => $temp)); 37 35 38 36 sfCacheDriverTests::launch($t, $cache); trunk/test/unit/cache/sfMemcacheCacheTest.php
r4658 r4957 27 27 // ->initialize() 28 28 $t->diag('->initialize()'); 29 $cache = sfCache::newInstance('sfMemcacheCache');29 $cache = new sfMemcacheCache(); 30 30 try 31 31 { trunk/test/unit/cache/sfNoCacheTest.php
r4579 r4957 15 15 // ->initialize() 16 16 $t->diag('->initialize()'); 17 $cache = sfCache::newInstance('sfNoCache');17 $cache = new sfNoCache(); 18 18 $cache->initialize(); 19 19 trunk/test/unit/cache/sfSQLiteCacheTest.php
r4579 r4957 23 23 // ->initialize() 24 24 $t->diag('->initialize()'); 25 $cache = sfCache::newInstance('sfSQLiteCache');26 25 try 27 26 { 28 $cache ->initialize();27 $cache = new sfSQLiteCache(); 29 28 $t->fail('->initialize() throws an sfInitializationException exception if you don\'t pass a "database" parameter'); 30 29 } … … 35 34 36 35 // database in memory 37 $cache = sfCache::newInstance('sfSQLiteCache'); 38 $cache->initialize(array('database' => ':memory:')); 36 $cache = new sfSQLiteCache(array('database' => ':memory:')); 39 37 40 38 sfCacheDriverTests::launch($t, $cache); … … 43 41 $database = tempnam('/tmp/cachedir', 'tmp'); 44 42 unlink($database); 45 $cache = sfCache::newInstance('sfSQLiteCache'); 46 $cache->initialize(array('database' => $database)); 43 $cache = new sfSQLiteCache(array('database' => $database)); 47 44 sfCacheDriverTests::launch($t, $cache); 48 45 unlink($database); trunk/test/unit/cache/sfXCacheCacheTest.php
r4579 r4957 27 27 // ->initialize() 28 28 $t->diag('->initialize()'); 29 $cache = sfCache::newInstance('sfXCacheCache');29 $cache = new sfXCacheCache(); 30 30 $cache->initialize(); 31 31 trunk/test/unit/config/fixtures/sfFilterConfigHandler/result.php
r2661 r4957 5 5 list($class, $parameters) = (array) sfConfig::get('sf_execution_filter', array('sfExecutionFilter', array ( 6 6 ))); 7 $filter = new $class(); 8 $filter->initialize($this->context, $parameters); 7 $filter = new $class($this->context, $parameters); 9 8 $filterChain->register($filter); 10 9 11 10 list($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); 14 12 $filterChain->register($filter); 15 13 … … 17 15 'key' => 'value', 18 16 ))); 19 $filter = new $class(); 20 $filter->initialize($this->context, $parameters); 17 $filter = new $class($this->context, $parameters); 21 18 $filterChain->register($filter); 22 19 … … 24 21 'key' => 'value', 25 22 ))); 26 $filter = new $class(); 27 $filter->initialize($this->context, $parameters); 23 $filter = new $class($this->context, $parameters); 28 24 $filterChain->register($filter); 29 25 trunk/test/unit/controller/sfControllerTest.php
r4951 r4957 21 21 $context = sfContext::getInstance(); 22 22 23 $controller = new myController(); 24 $controller->initialize($context); 23 $controller = new myController($context); 25 24 26 25 // new methods via sfEventDispatcher trunk/test/unit/controller/sfWebControllerTest.php
r4951 r4957 24 24 )); 25 25 26 $controller = sfController::newInstance('sfFrontWebController'); 27 $controller->initialize($context, null); 26 $controller = new sfFrontWebController($context, null); 28 27 29 28 $tests = array( trunk/test/unit/generator/sfGeneratorTest.php
r4951 r4957 19 19 20 20 $manager = new sfGeneratorManager(); 21 $generator = new myGenerator(); 22 $generator->initialize($manager); 21 $generator = new myGenerator($manager); trunk/test/unit/log/sfAggregateLoggerTest.php
r4951 r4957 21 21 unlink($file); 22 22 } 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); 26 25 27 26 // ->initialize() 28 27 $t->diag('->initialize()'); 29 $logger = sfLogger::newInstance('sfAggregateLogger'); 30 $logger->initialize($dispatcher, array('loggers' => $fileLogger)); 28 $logger = new sfAggregateLogger($dispatcher, array('loggers' => $fileLogger)); 31 29 $t->is($logger->getLoggers(), array($fileLogger), '->initialize() can take a "loggers" parameter'); 32 30 33 $logger = sfLogger::newInstance('sfAggregateLogger'); 34 $logger->initialize($dispatcher, array('loggers' => array($fileLogger, $consoleLogger))); 31 $logger = new sfAggregateLogger($dispatcher, array('loggers' => array($fileLogger, $consoleLogger))); 35 32 $t->is($logger->getLoggers(), array($fileLogger, $consoleLogger), '->initialize() can take a "loggers" parameter'); 36 33 … … 45 42 46 43 // ->getLoggers() ->addLoggers() ->addLogger() 47 $logger = sfLogger::newInstance('sfAggregateLogger');44 $logger = new sfAggregateLogger($dispatcher); 48 45 $logger->addLogger($fileLogger); 49 46 $t->is($logger->getLoggers(), array($fileLogger), '->addLogger() adds a new sfLogger instance'); 50 47 51 $logger = sfLogger::newInstance('sfAggregateLogger');48 $logger = new sfAggregateLogger($dispatcher); 52 49 $logger->addLoggers(array($fileLogger, $consoleLogger)); 53 50 $t->is($logger->getLoggers(), array($fileLogger, $consoleLogger), '->addLoggers() adds an array of sfLogger instances'); trunk/test/unit/log/sfConsoleLoggerTest.php
r4845 r4957 13 13 $t = new lime_test(1, new lime_output_color()); 14 14 15 $logger = sfLogger::newInstance('sfConsoleLogger');15 $logger = new sfConsoleLogger(new sfEventDispatcher()); 16 16 ob_start(); 17 17 $logger->log('foo'); trunk/test/unit/log/sfFileLoggerTest.php
r4951 r4957 24 24 // ->initialize() 25 25 $t->diag('->initialize()'); 26 $logger = sfLogger::newInstance('sfFileLogger');27 26 try 28 27 { 29 $logger ->initialize($dispatcher);28 $logger = new sfFileLogger($dispatcher); 30 29 $t->fail('->initialize() parameters must contains a "file" parameter'); 31 30 } … … 37 36 // ->log() 38 37 $t->diag('->log()'); 39 $logger ->initialize($dispatcher, array('file' => $file));38 $logger = new sfFileLogger($dispatcher, array('file' => $file)); 40 39 $logger->log('foo'); 41 40 $lines = explode("\n", file_get_contents($file)); trunk/test/unit/log/sfLoggerTest.php
r4951 r4957 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(13 7, new lime_output_color());13 $t = new lime_test(135, new lime_output_color()); 14 14 15 15 class myLogger extends sfLogger … … 28 28 29 29 $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); 44 31 45 32 // ->setLogLevel() ->getLogLevel() trunk/test/unit/request/sfRequestTest.php
r4951 r4957 23 23 } 24 24 25 $t = new lime_test(5 3, new lime_output_color());25 $t = new lime_test(50, new lime_output_color()); 26 26 27 27 $dispatcher = new sfEventDispatcher(); 28 28 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 try35 {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 44 29 // ->initialize() 45 30 $t->diag('->initialize()'); 46 $request = sfRequest::newInstance('myRequest'); 47 $request->initialize($dispatcher); 31 $request = new myRequest($dispatcher); 48 32 $t->is($dispatcher, $request->getEventDispatcher(), '->initialize() takes a sfEventDispatcher object as its first argument'); 49 33 $request->initialize($dispatcher, array('foo' => 'bar')); … … 72 56 $t->is($request->extractParameters(array('bar')), array('bar' => 'bar'), '->extractParameters() returns parameters for keys in its first parameter'); 73 57 74 $request = sfRequest::newInstance('myRequest'); 75 $request->initialize($dispatcher); 58 $request = new myRequest($dispatcher); 76 59 77 60 // ->setError() ->hasError() ->hasErrors() ->getError() ->removeError() ->getErrorNames trunk/test/unit/request/sfWebRequestTest.php
r4440 r4957 20 20 } 21 21 22 $request = sfRequest::newInstance('myRequest'); 22 $dispatcher = new sfEventDispatcher(); 23 $request = new myRequest($dispatcher); 23 24 24 25 // ->getLanguages() trunk/test/unit/response/sfResponseTest.php
r4951 r4957 21 21 } 22 22 23 $t = new lime_test(2 3, new lime_output_color());23 $t = new lime_test(20, new lime_output_color()); 24 24 25 25 $dispatcher = new sfEventDispatcher(); 26 26 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 try33 {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 42 27 // ->initialize() 43 28 $t->diag('->initialize()'); 44 $response = sfResponse::newInstance('myResponse'); 45 $response->initialize($dispatcher, array('foo' => 'bar')); 29 $response = new myResponse($dispatcher, array('foo' => 'bar')); 46 30 $t->is($response->getParameter('foo'), 'bar', '->initialize() takes an array of parameters as its second argument'); 47 31 … … 61 45 // ->serialize() ->unserialize() 62 46 $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'); 64 48 65 49 // parameter holder proxy 66 50 require_once($_test_dir.'/unit/sfParameterHolderTest.class.php'); 67 $response = sfResponse::newInstance('myResponse'); 68 $response->initialize($dispatcher); 51 $response = new myResponse($dispatcher); 69 52 $pht = new sfParameterHolderProxyTest($t); 70 53 $pht->launchTests($response, 'parameter'); trunk/test/unit/response/sfWebResponseTest.php
r4951 r4957 28 28 $dispatcher = new sfEventDispatcher(); 29 29 30 $response = new myWebResponse(); 31 $response->initialize($dispatcher); 30 $response = new myWebResponse($dispatcher); 32 31 33 32 // ->getStatusCode() ->setStatusCode() … … 162 161 // ->mergeProperties() 163 162 $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); 168 165 169 166 $response1->setHttpHeader('symfony', 'foo'); … … 178 175 // ->addStylesheet() 179 176 $t->diag('->addStylesheet()'); 180 $response = sfResponse::newInstance('myWebResponse'); 181 $response->initialize($dispatcher); 177 $response = new myWebResponse($dispatcher); 182 178 $response->addStylesheet('test'); 183 179 $t->ok($response->getParameterHolder()->has('test', 'helper/asset/auto/stylesheet'), '->addStylesheet() adds a new stylesheet for the response'); … … 199 195 // ->addJavascript() 200 196 $t->diag('->addJavascript()'); 201 $response = sfResponse::newInstance('myWebResponse'); 202 $response->initialize($dispatcher); 197 $response = new myWebResponse($dispatcher); 203 198 $response->addJavascript('test'); 204 199 $t->ok($response->getParameterHolder()->has('test', 'helper/asset/auto/javascript'), '->addJavascript() adds a new javascript for the response'); … … 223 218 // ->setHeaderOnly() ->getHeaderOnly() 224 219 $t->diag('->setHeaderOnly() ->isHeaderOnly()'); 225 $response = sfResponse::newInstance('myWebResponse'); 226 $response->initialize($dispatcher); 220 $response = new myWebResponse($dispatcher); 227 221 $t->is($response->isHeaderOnly(), false, '->isHeaderOnly() returns false if the content must be send to the client'); 228 222 $response->setHeaderOnly(true); trunk/test/unit/routing/sfNoRoutingTest.php
r4951 r4957 13 13 $t = new lime_test(12, new lime_output_color()); 14 14 15 $routing = new sfNoRouting(); 16 $routing->initialize(new sfEventDispatcher()); 15 $routing = new sfNoRouting(new sfEventDispatcher()); 17 16 18 17 // ->getCurrentInternalUri() trunk/test/unit/routing/sfPathInfoRoutingTest.php
r4951 r4957 13 13 $t = new lime_test(12, new lime_output_color()); 14 14 15 $routing = new sfPathInfoRouting(); 16 $routing->initialize(new sfEventDispatcher()); 15 $routing = new sfPathInfoRouting(new sfEventDispatcher()); 17 16 18 17 // ->getCurrentInternalUri() trunk/test/unit/routing/sfPatternRoutingTest.php
r4951 r4957 22 22 23 23 // public methods 24 $r = new sfPatternRoutingTest(); 25 $r->initialize(new sfEventDispatcher()); 24 $r = new sfPatternRoutingTest(new sfEventDispatcher()); 26 25 foreach (array('clearRoutes', 'connect', 'generate', 'getCurrentInternalUri', 'getCurrentRouteName', 'getRoutes', 'hasRoutes', 'parse', 'setRoutes') as $method) 27 26 { trunk/test/unit/sfContextMock.class.php
r4951 r4957 28 28 self::$instance = new sfContext(); 29 29 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')); 32 31 33 32 self::$instance->dispatcher = new sfEventDispatcher(); … … 89 88 public function inject($type, $class, $parameters = array()) 90 89 { 91 $object = new $class(); 92 if (method_exists($object, 'initialize')) 90 switch ($type) 93 91 { 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); 106 101 } 102 107 103 $this->$type = $object; 108 104 } trunk/test/unit/storage/sfNoStorageTest.php
r4890 r4957 14 14 15 15 // initialize the storage 16 $storage = sfStorage::newInstance('sfNoStorage'); 17 $storage->initialize(); 16 $storage = new sfNoStorage(); 18 17 19 18 $t->ok($storage instanceof sfStorage, 'sfNoStorage is an instance of sfStorage'); trunk/test/unit/storage/sfPDOSessionStorageTest.php
r4890 r4957 20 20 21 21 // initialize the storage 22 $database = new sfPDODatabase(); 23 $database->initialize(array('dsn' => 'sqlite::memory:')); 22 $database = new sfPDODatabase(array('dsn' => 'sqlite::memory:')); 24 23 $connection = $database->getConnection(); 25 24 $connection->exec('CREATE TABLE session (sess_id, sess_data, sess_time)'); … … 28 27 $session_id = "1"; 29 28 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)); 32 30 $t->ok($storage instanceof sfStorage, 'sfPDOSessionStorage is an instance of sfStorage'); 33 31 $t->ok($storage instanceof sfDatabaseSessionStorage, 'sfPDOSessionStorage is an instance of sfDatabaseSessionStorage'); trunk/test/unit/storage/sfStorageTest.php
r4890 r4957 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(1 7, new lime_output_color());13 $t = new lime_test(14, new lime_output_color()); 14 14 15 15 class myStorage extends sfStorage … … 25 25 } 26 26 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 try33 {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 42 27 // ->initialize() 43 28 $t->diag('->initialize()'); 44 $storage = sfStorage::newInstance('myStorage'); 45 $storage->initialize(array('foo' => 'bar')); 29 $storage = new myStorage(array('foo' => 'bar')); 46 30 $t->is($storage->getParameter('foo'), 'bar', '->initialize() takes an array of parameters as its second argument'); 47 31 48 32 $storage = new myStorage(); 49 $storage->initialize();50 33 51 34 // parameter holder proxy trunk/test/unit/task/cache/sfCacheClearTaskTest.php
r4743 r4957 13 13 $t = new lime_test(2, new lime_output_color()); 14 14 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')); 17 19 18 20 sfCore::initDirectoryLayout(sfConfig::get('sf_root_dir'), 'frontend', 'dev'); … … 25 27 $t->ok(file_exists($file), 'The test file is in the cache'); 26 28 27 sfTask::newInstance('sfCacheClearTask')->run(); 29 $task = new sfCacheClearTask(); 30 $task->run(); 28 31 29 32 $t->ok(!file_exists($file), 'The test file is removed by the cache:clear task'); trunk/test/unit/user/sfBasicSecurityUserTest.php
r4951 r4957 14 14 15 15 $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')); 18 17 19 $user = new sfBasicSecurityUser(); 20 $user->initialize($dispatcher, $storage); 18 $user = new sfBasicSecurityUser($dispatcher, $storage); 21 19 22 20 // ->initialize() … … 25 23 /* 26 24 sfConfig::set('sf_timeout', 0); 27 $user = new sfBasicSecurityUser(); 28 $user->initialize($context); 25 $user = new sfBasicSecurityUser($context); 29 26 $t->is($user->isTimedOut(), true, '->initialize() times out the user if no request made for a long time'); 30 27 */ … … 46 43 // ->setTimedOut() ->getTimedOut() 47 44 sfConfig::set('sf_timeout', 86400); 48 $user = new sfBasicSecurityUser(); 49 $user->initialize($dispatcher, $storage); 45 $user = new sfBasicSecurityUser($dispatcher, $storage); 50 46 $t->diag('->setTimedOut() ->isTimedOut()'); 51 47 $t->is($user->isTimedOut(), false, '->isTimedOut() returns false if the session is not timed out'); trunk/test/unit/user/sfUserTest.php
r4951 r4957 17 17 18 18 $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')); 21 20 22 $user = new sfUser(); 23 $user->initialize($dispatcher, $storage); 21 $user = new sfUser($dispatcher, $storage); 24 22 25 23 // ->initialize() … … 38 36 $t->is($user->getCulture(), 'de', '->initialize() reads the culture from the session data if available'); 39 37 40 $userBis = new sfUser(); 41 $userBis->initialize($dispatcher, $storage); 38 $userBis = new sfUser($dispatcher, $storage); 42 39 $t->is($userBis->getCulture(), 'de', '->initialize() serializes the culture to the session data'); 43 40 … … 55 52 user_flush($dispatcher, $user, $storage, array('use_flash' => true)); 56 53 57 $userBis = new sfUser(); 58 $userBis->initialize($dispatcher, $storage, array('use_flash' => true)); 54 $userBis = new sfUser($dispatcher, $storage, array('use_flash' => true)); 59 55 $t->is($userBis->getFlash('foo'), 'bar', '->getFlash() returns a flash previously set'); 60 56 $t->is($userBis->hasFlash('foo'), true, '->hasFlash() returns true if the flash variable exists'); 61 57 user_flush($dispatcher, $user, $storage, array('use_flash' => true)); 62 58 63 $userBis = new sfUser(); 64 $userBis->initialize($dispatcher, $storage, array('use_flash' => true)); 59 $userBis = new sfUser($dispatcher, $storage, array('use_flash' => true)); 65 60 $t->is($userBis->getFlash('foo'), null, 'Flashes are automatically removed after the next request'); 66 61 $t->is($userBis->hasFlash('foo'), false, '->hasFlash() returns true if the flash variable exists'); trunk/test/unit/validator/sfCallbackValidatorTest.php
r4440 r4957 15 15 16 16 $context = sfContext::getInstance(); 17 $v = new sfCallbackValidator();18 17 19 18 // ->initialize() … … 22 21 try 23 22 { 24 $v ->initialize($context);23 $v = new sfCallbackValidator($context); 25 24 $t->fail('->initialize() takes a mandatory "callback" parameter'); 26 25 } … … 32 31 try 33 32 { 34 $v ->initialize($context, array('callback' => 'arandomstring'));33 $v = new sfCallbackValidator($context, array('callback' => 'arandomstring')); 35 34 $t->fail('->initialize() takes a callable as a "callback" parameter'); 36 35 } … … 58 57 } 59 58 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'); 63 62 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"'); 65 64 $value = false; 66 65 $error = null; … … 70 69 // ->execute() 71 70 $t->diag('->execute()'); 72 $ v->initialize($context, array('callback' => 'callbackValidator'));71 $c = new sfCallbackValidator($context, array('callback' => 'callbackValidator')); 73 72 74 73 $value = true; trunk/test/unit/validator/sfCompareValidatorTest.php
r4440 r4957 28 28 $request = $context->request; 29 29 30 $v = new sfCompareValidator();31 30 $h = new sfValidatorTestHelper($context, $t); 32 31 … … 34 33 try 35 34 { 36 $v ->initialize($context);35 $v = new sfCompareValidator($context); 37 36 $t->fail('->initialize() takes a required "check" parameter'); 38 37 } … … 44 43 try 45 44 { 46 $v ->initialize($context, array('check' => 'value', 'operator' => 'N'));45 $v = new sfCompareValidator($context, array('check' => 'value', 'operator' => 'N')); 47 46 $t->fail('->initialize() takes an "operator" parameter in (>, >=, <, <=, ==, !=)'); 48 47 } … … 54 53 // == operator (default operator) 55 54 $t->diag('->execute() - == operator (default operator)'); 55 $v = new sfCompareValidator($context, array('check' => 'value')); 56 56 $request->parameters = array('value2' => 'azerty'); 57 57 $options = array('check' => 'value2'); trunk/test/unit/validator/sfRegexValidatorTest.php
r4440 r4957 15 15 16 16 $context = sfContext::getInstance(); 17 $v = new sfRegexValidator();18 17 19 18 // ->initialize() … … 22 21 try 23 22 { 24 $v ->initialize($context);23 $v = new sfRegexValidator($context); 25 24 $t->fail('->initialize() takes a mandatory "pattern" parameter'); 26 25 } … … 30 29 } 31 30 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'); 33 32 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')); 35 34 $value = 'a string'; 36 35 $error = null; trunk/test/unit/view/sfViewCacheManagerTest.php
r4579 r4957 12 12 require_once($_test_dir.'/unit/sfContextMock.class.php'); 13 13 14 $t = new lime_test(1 2, new lime_output_color());14 $t = new lime_test(11, new lime_output_color()); 15 15 16 16 class myController extends sfWebController … … 92 92 // ->initialize() 93 93 $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'); 101 96 102 97 // ->generateNamespace() … … 149 144 { 150 145 myCache::clear(); 151 $m = new sfViewCacheManager(); 152 $m->initialize($context, new myCache()); 146 $m = new sfViewCacheManager($context, new myCache()); 153 147 154 148 return $m; trunk/test/unit/view/sfViewTest.php
r4951 r4957 37 37 38 38 $context = sfContext::getInstance(); 39 $view = new myView(); 40 $view->initialize($context, '', '', ''); 39 $view = new myView($context, '', '', ''); 41 40 42 41 // ->isDecorator() ->setDecorator()

