Changeset 3703
- Timestamp:
- 04/03/07 08:23:18 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
doc/trunk/book/19-Mastering-Symfony-s-Configuration-Files.txt
r3568 r3703 514 514 >The `class` must either be autoloaded (that's the case here) or defined in the file whose path is written in a `file` parameter under the `param` key. 515 515 516 As with many other symfony configuration files, you can also register a configuration handler directly in your PHP code: 517 518 sfConfigCache::getInstance()->registerConfigHandler('config/map.yml', myMapConfigHandler, array()); 519 516 520 When you need the code based on the `map.yml` file and generated by the `myMapConfigHandler` handler in your application, call the following line: 517 521 trunk/lib/config/sfConfigCache.class.php
r3525 r3703 24 24 { 25 25 protected 26 $handlers = array(); 26 $handlers = array(), 27 $userHandlers = array(); 27 28 28 29 protected static … … 59 60 // we need to load the handlers first 60 61 $this->loadConfigHandlers(); 62 } 63 64 if (count($this->userHandlers) != 0) 65 { 66 // we load user defined handlers 67 $this->mergeUserConfigHandlers(); 61 68 } 62 69 … … 319 326 { 320 327 // module directory doesn't exist or isn't readable 321 $error = sprintf('Module directory "%s" does not exist or is not readable', 322 sfConfig::get('sf_app_module_dir')); 328 $error = sprintf('Module directory "%s" does not exist or is not readable', sfConfig::get('sf_app_module_dir')); 323 329 throw new sfConfigurationException($error); 324 330 } … … 340 346 $fileCache->set(basename($cache), '', $data); 341 347 } 348 349 /** 350 * Registers a configuration handler. 351 * 352 * @param string The handler to use when parsing a configuration file 353 * @param class A configuration handler class 354 * @param string An array of options for the handler class initialization 355 */ 356 public function registerConfigHandler($handler, $class, $params = array()) 357 { 358 $this->userHandlers[$handler] = new $class(); 359 $this->userHandlers[$handler]->initialize($params); 360 } 361 362 /** 363 * Merges configuration handlers from the config_handlers.yml 364 * and the ones defined with registerConfigHandler() 365 * 366 */ 367 protected function mergeUserConfigHandlers() 368 { 369 // user defined configuration handlers 370 $this->handlers = array_merge($this->handlers, $this->userHandlers); 371 372 $this->userHandlers = array(); 373 } 342 374 }