Changeset 7341
- Timestamp:
- 02/04/08 18:07:31 (7 months ago)
- Files:
-
- branches/1.1/lib/config/sfConfigCache.class.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/config/sfConfigCache.class.php
r5902 r7341 68 68 } 69 69 70 // handler to call for this configuration file71 $handler ToCall= null;70 // handler key to call for this configuration file 71 $handlerKey = null; 72 72 73 73 $handler = str_replace(DIRECTORY_SEPARATOR, '/', $handler); … … 78 78 { 79 79 // we have a handler associated with the full configuration path 80 $handler ToCall = $this->handlers[$handler];80 $handlerKey = $handler; 81 81 } 82 82 else if (isset($this->handlers[$basename])) 83 83 { 84 84 // we have a handler associated with the configuration base name 85 $handler ToCall = $this->handlers[$basename];85 $handlerKey = $basename; 86 86 } 87 87 else 88 88 { 89 // let's see if we have any wildcard handlers registered that match 90 // this basename 91 foreach ($this->handlers as $key => $handlerInstance) 89 // let's see if we have any wildcard handlers registered that match this basename 90 foreach (array_keys($this->handlers) as $key) 92 91 { 93 92 // replace wildcard chars in the configuration … … 95 94 96 95 // create pattern from config 97 if (preg_match('#'.$pattern.' #', $handler))96 if (preg_match('#'.$pattern.'$#', $handler)) 98 97 { 99 // we found a match! 100 $handlerToCall = $this->handlers[$key]; 98 $handlerKey = $key; 101 99 102 100 break; … … 105 103 } 106 104 107 if ($handlerToCall) 108 { 109 // call the handler and retrieve the cache data 110 $data = $handlerToCall->execute($configs); 111 112 $this->writeCacheFile($handler, $cache, $data); 113 } 114 else 105 if (!$handlerKey) 115 106 { 116 107 // we do not have a registered handler for this file 117 108 throw new sfConfigurationException(sprintf('Configuration file "%s" does not have a registered handler.', implode(', ', $configs))); 118 109 } 110 111 // call the handler and retrieve the cache data 112 $data = $this->getHandler($handlerKey)->execute($configs); 113 114 $this->writeCacheFile($handler, $cache, $data); 115 } 116 117 /** 118 * Returns the config handler configured for the given name 119 * 120 * @param string The config handler name 121 * 122 * @return sfConfigHandler A sfConfigHandler instance 123 */ 124 protected function getHandler($name) 125 { 126 if (is_array($this->handlers[$name])) 127 { 128 $class = $this->handlers[$name][0]; 129 $this->handlers[$name] = new $class($this->handlers[$name][1]); 130 } 131 132 return $this->handlers[$name]; 119 133 } 120 134