Changeset 2064
- Timestamp:
- 08/23/07 01:13:19 (17 months ago)
- Location:
- branches/0.11
- Files:
-
- 11 modified
-
src/config/AgaviConfig.class.php (modified) (3 diffs)
-
src/config/AgaviConfigCache.class.php (modified) (11 diffs)
-
src/config/AgaviModuleConfigHandler.class.php (modified) (2 diffs)
-
src/config/AgaviSettingConfigHandler.class.php (modified) (2 diffs)
-
src/controller/AgaviExecutionContainer.class.php (modified) (40 diffs)
-
src/core/Agavi.class.php (modified) (6 diffs)
-
src/request/AgaviWebRequest.class.php (modified) (21 diffs)
-
src/routing/AgaviWebRouting.class.php (modified) (14 diffs)
-
tests2/config/AgaviConfigTest.php (modified) (4 diffs)
-
tests2/config/ConfigCacheTest.php (modified) (4 diffs)
-
tests2/config/FactoryConfigHandlerTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.11/src/config/AgaviConfig.class.php
r1991 r2064 15 15 16 16 /** 17 * AgaviConfig acts as global registry of agavi related configuration settings 17 * AgaviConfig acts as global registry of agavi related configuration settings 18 18 * 19 19 * @package agavi … … 143 143 * @since 0.11.0 144 144 */ 145 public static function import($data)145 public static function fromArray($data) 146 146 { 147 147 self::$config = array_merge(array_merge(self::$config, $data), self::$readonlies); … … 156 156 * @since 0.11.0 157 157 */ 158 public static function toArray() 159 { 160 return self::$config; 161 } 162 163 /** 164 * Get all configuration directives and values. 165 * 166 * @return array An associative array of configuration values. 167 * 168 * @deprecated Use toArray() instead. 169 * 170 * @author David Zülke <dz@bitxtender.com> 171 * @since 0.11.0 172 */ 158 173 public static function export() 159 174 { 160 return self:: $config;175 return self::toArray(); 161 176 } 162 177 -
branches/0.11/src/config/AgaviConfigCache.class.php
r1983 r2064 63 63 self::loadConfigHandlers(); 64 64 } 65 65 66 66 // grab the base name of the handler 67 67 $basename = basename($name); 68 68 69 69 $handlerInfo = null; 70 70 71 71 if(isset(self::$handlers[$name])) { 72 72 // we have a handler associated with the full configuration path … … 81 81 // replace wildcard chars in the configuration and create the pattern 82 82 $pattern = sprintf('#%s#', str_replace('\*', '.*?', preg_quote($key))); 83 83 84 84 if(preg_match($pattern, $name)) { 85 85 $handlerInfo = $value; … … 88 88 } 89 89 } 90 90 91 91 if($handlerInfo === null) { 92 92 // we do not have a registered handler for this file … … 95 95 throw new AgaviConfigurationException($error); 96 96 } 97 97 98 98 // call the handler and retrieve the cache data 99 99 $handler = new $handlerInfo['class']; … … 103 103 $parser = new AgaviXmlConfigParser(); 104 104 $docs = $parser->parseAll($config, $handlerInfo['validation']); 105 105 106 106 if($context !== null) { 107 107 $context = AgaviContext::getInstance($context); 108 108 } 109 109 110 110 $handler->initialize($context, $handlerInfo['parameters']); 111 111 112 112 try { 113 113 $data = $handler->execute($docs); … … 123 123 $data = $handler->execute($config, $context); 124 124 } 125 125 126 126 self::writeCacheFile($config, $cache, $data, false); 127 127 } … … 141 141 * associated with this specified configuration file. 142 142 * 143 * @throws <b>AgaviUnreadableException</b> If a requested configuration 143 * @throws <b>AgaviUnreadableException</b> If a requested configuration 144 144 * file does not exist. 145 145 * … … 167 167 return $cache; 168 168 } 169 169 170 170 /** 171 171 * Check if the cached version of a file is up to date. … … 249 249 * @since 0.9.0 250 250 */ 251 public static function import($config, $context = null, $once = true)251 public static function load($config, $context = null, $once = true) 252 252 { 253 253 $cache = self::checkConfig($config, $context); … … 287 287 // manually create our config_handlers.xml handler 288 288 self::$handlers['config_handlers.xml'] = array( 289 'class' => 'AgaviConfigHandlersConfigHandler', 289 'class' => 'AgaviConfigHandlersConfigHandler', 290 290 'parameters' => array( 291 291 ), … … 366 366 { 367 367 $parser = new AgaviConfigParser(); 368 368 369 369 return $parser->parse($config, $validationFile); 370 370 } -
branches/0.11/src/config/AgaviModuleConfigHandler.class.php
r1969 r2064 16 16 17 17 /** 18 * AgaviModuleConfigHandler reads module configuration files to determine the 18 * AgaviModuleConfigHandler reads module configuration files to determine the 19 19 * status of a module. 20 20 * … … 88 88 } 89 89 90 $code = 'AgaviConfig:: import(' . var_export($data, true) . ');';90 $code = 'AgaviConfig::fromArray(' . var_export($data, true) . ');'; 91 91 92 92 return $this->generate($code); -
branches/0.11/src/config/AgaviSettingConfigHandler.class.php
r1969 r2064 79 79 } 80 80 } 81 81 82 82 if($cfg->hasChildren('exception_templates')) { 83 83 foreach($cfg->exception_templates->getChildren() as $exception_template) { … … 97 97 } 98 98 99 $code = 'AgaviConfig:: import(' . var_export($data, true) . ');';99 $code = 'AgaviConfig::fromArray(' . var_export($data, true) . ');'; 100 100 101 101 return $this->generate($code); -
branches/0.11/src/controller/AgaviExecutionContainer.class.php
r2061 r2064 17 17 * A container used for each action execution that holds neecessary information, 18 18 * such as the output type, the response etc. 19 * 19 * 20 20 * @package agavi 21 21 * @subpackage controller 22 * 22 * 23 23 * @author David Zülke <dz@bitxtender.com> 24 24 * @copyright Authors … … 35 35 */ 36 36 protected $context = null; 37 37 38 38 /** 39 39 * @var AgaviValidationManager The validation manager instance. 40 40 */ 41 41 protected $validationManager = null; 42 42 43 43 /** 44 44 * @var AgaviRequestDataHolder A request data holder with request info. 45 45 */ 46 46 protected $requestData = null; 47 47 48 48 /** 49 49 * @var AgaviRequestDataHolder A request data holder with arguments. 50 50 */ 51 51 protected $arguments = null; 52 52 53 53 /** 54 54 * @var AgaviResponse A response instance holding the Action's output. 55 55 */ 56 56 protected $response = null; 57 57 58 58 /** 59 59 * @var AgaviOutputType The output type for this container. 60 60 */ 61 61 protected $outputType = null; 62 62 63 63 /** 64 64 * @var float The microtime at which this container was initialized. 65 65 */ 66 66 protected $microtime = null; 67 67 68 68 /** 69 69 * @var AgaviAction The Action instance that belongs to this container. … … 80 80 */ 81 81 protected $moduleName = null; 82 82 83 83 /** 84 84 * @var string The name of the Action. 85 85 */ 86 86 protected $actionName = null; 87 87 88 88 /** 89 89 * @var string Name of the module of the View returned by the Action. 90 90 */ 91 91 protected $viewModuleName = null; 92 92 93 93 /** 94 94 * @var string The name of the View returned by the Action. 95 95 */ 96 96 protected $viewName = null; 97 97 98 98 /** 99 99 * @var AgaviExecutionContainer The next container to execute. 100 100 */ 101 101 protected $next = null; 102 102 103 103 /** 104 104 * Pre-serialization callback. … … 118 118 return array_keys($arr); 119 119 } 120 120 121 121 /** 122 122 * Post-unserialization callback. … … 134 134 unset($this->contextName, $this->outputTypeName); 135 135 } 136 136 137 137 /** 138 138 * Initialize the container. This will create a response instance. … … 147 147 { 148 148 $this->microtime = microtime(true); 149 149 150 150 $this->context = $context; 151 151 152 152 $this->parameters = $parameters; 153 153 } 154 154 155 155 /** 156 156 * Creates a new container instance with the same output type as this one. … … 176 176 return $this->context->getController()->createExecutionContainer($moduleName, $actionName, $arguments, $outputType); 177 177 } 178 178 179 179 /** 180 180 * Start execution. … … 196 196 { 197 197 $controller = $this->context->getController(); 198 198 199 199 $request = $this->context->getRequest(); 200 200 201 201 $controller->countExecution(); 202 202 203 203 $moduleName = $this->getModuleName(); 204 204 $actionName = $this->getActionName(); 205 205 206 206 if(!AgaviConfig::get('core.available', false)) { 207 207 // application is unavailable … … 248 248 } 249 249 } 250 250 251 251 $this->setModuleName($moduleName); 252 252 $this->setActionName($actionName); 253 253 254 254 // include the module configuration 255 // l aoded only once due to the way import() works255 // loaded only once due to the way load() (former import()) works 256 256 if(is_readable(AgaviConfig::get('core.module_dir') . '/' . $moduleName . '/config/module.xml')) { 257 AgaviConfigCache:: import(AgaviConfig::get('core.module_dir') . '/' . $moduleName . '/config/module.xml', $this->context->getName());257 AgaviConfigCache::load(AgaviConfig::get('core.module_dir') . '/' . $moduleName . '/config/module.xml', $this->context->getName()); 258 258 } else { 259 259 AgaviConfig::set('modules.' . strtolower($moduleName) . '.enabled', true); … … 262 262 // save autoloads so we can restore them later 263 263 $oldAutoloads = Agavi::$autoloads; 264 264 265 265 static $moduleAutoloads = array(); 266 266 if(!isset($moduleAutoloads[$moduleName])) { … … 274 274 Agavi::$autoloads = array_merge($moduleAutoloads[$moduleName], Agavi::$autoloads); 275 275 } 276 276 277 277 if(AgaviConfig::get('modules.' . strtolower($moduleName) . '.enabled')) { 278 278 // check for a module config.php … … 281 281 require_once($moduleConfig); 282 282 } 283 283 284 284 $this->actionInstance = $controller->createActionInstance($this->moduleName, $this->actionName); 285 285 286 286 // initialize the action 287 287 $this->actionInstance->initialize($this); 288 288 289 289 if($this->actionInstance->isSimple()) { 290 290 if($this->arguments !== null) { … … 298 298 } else { 299 299 $this->requestData = clone $request->getRequestData(); 300 300 301 301 if($this->arguments !== null) { 302 302 $this->requestData->merge($this->arguments); 303 303 } 304 304 305 305 // create a new filter chain 306 306 $fcfi = $this->context->getFactoryInfo('filter_chain'); … … 329 329 $filterChain->execute($this); 330 330 } 331 331 332 332 // restore autoloads 333 333 Agavi::$autoloads = $oldAutoloads; 334 334 335 335 } else { 336 336 337 337 $request->setAttributes(array( 338 338 'requested_module' => $moduleName, … … 350 350 throw new AgaviConfigurationException($error); 351 351 } 352 352 353 353 $this->setNext($controller->createExecutionContainer($moduleName, $actionName)); 354 354 } 355 355 356 356 if($this->next !== null) { 357 357 return $this->next->execute(); … … 360 360 } 361 361 } 362 362 363 363 /** 364 364 * Get the Context. … … 373 373 return $this->context; 374 374 } 375 375 376 376 /** 377 377 * Retrieve the ValidationManager 378 378 * 379 * @return AgaviValidationManager The container's ValidationManager 379 * @return AgaviValidationManager The container's ValidationManager 380 380 * implementation instance. 381 381 * … … 392 392 return $this->validationManager; 393 393 } 394 394 395 395 /** 396 396 * Retrieve this container's request data holder instance. … … 405 405 return $this->requestData; 406 406 } 407 407 408 408 /** 409 409 * Get this container's request data holder instance for additional arguments. … … 418 418 return $this->arguments; 419 419 } 420 420 421 421 /** 422 422 * Set this container's request data holder instance for additional arguments. … … 431 431 $this->arguments = $arguments; 432 432 } 433 433 434 434 /** 435 435 * Retrieve this container's response instance. … … 444 444 return $this->response; 445 445 } 446 446 447 447 /** 448 448 * Set a new response. … … 457 457 $this->response = $response; 458 458 } 459 459 460 460 /** 461 461 * Retrieve the output type of this container. … … 470 470 return $this->outputType; 471 471 } 472 472 473 473 /** 474 474 * Set a different output type for this container. … … 483 483 $this->outputType = $outputType; 484 484 } 485 485 486 486 /** 487 487 * Retrieve this container's microtime. … … 497 497 return $this->microtime; 498 498 } 499 499 500 500 /** 501 501 * Retrieve this container's action instance. … … 510 510 return $this->actionInstance; 511 511 } 512 512 513 513 /** 514 514 * Retrieve this container's view instance. … … 523 523 return $this->viewInstance; 524 524 } 525 525 526 526 /** 527 527 * Set this container's view instance. … … 536 536 return $this->viewInstance = $viewInstance; 537 537 } 538 538 539 539 /** 540 540 * Retrieve this container's module name. … … 549 549 return $this->moduleName; 550 550 } 551 551 552 552 /** 553 553 * Retrieve this container's action name. … … 562 562 return $this->actionName; 563 563 } 564 565 /** 566 * Retrieve this container's view module name. This is the name of the module of 564 565 /** 566 * Retrieve this container's view module name. This is the name of the module of 567 567 * the View returned by the Action. 568 568 * … … 576 576 return $this->viewModuleName; 577 577 } 578 578 579 579 /** 580 580 * Retrieve this container's view name. … … 589 589 return $this->viewName; 590 590 } 591 591 592 592 /** 593 593 * Set the module name for this container. … … 602 602 $this->moduleName = preg_replace('/[^a-z0-9\-_]+/i', '', $moduleName); 603 603 } 604 604 605 605 /** 606 606 * Set the action name for this container. … … 615 615 $this->actionName = preg_replace(array('/\./', '/[^a-z0-9\-_\/]+/i'), array('/', ''), $actionName); 616 616 } 617 617 618 618 /** 619 619 * Set the view module name for this container. … … 628 628 $this->viewModuleName = $viewModuleName; 629 629 } 630 630 631 631 /** 632 632 * Set the module name for this container. … … 641 641 $this->viewName = $viewName; 642 642 } 643 643 644 644 /** 645 645 * Check if a "next" container has been set. … … 654 654 return $this->next !== null; 655 655 } 656 656 657 657 /** 658 658 * Get the "next" container. … … 667 667 return $this->next; 668 668 } 669 669 670 670 /** 671 671 * Set the container that should be executed once this one finished running. … … 680 680 $this->next = $container; 681 681 } 682 682
