* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * @package symfony * @subpackage config * @author Fabien Potencier * @version SVN: $Id: sfRoutingConfigHandler.class.php 3203 2007-01-09 18:32:54Z fabien $ */ class sfRoutingConfigHandler extends sfYamlConfigHandler { /** * Executes this configuration handler. * * @param array An array of absolute filesystem path to a configuration file * * @return string Data to be written to a cache file * * @throws sfConfigurationException If a requested configuration file does not exist or is not readable * @throws sfParseException If a requested configuration file is improperly formatted */ public function execute($configFiles) { // parse the yaml $config = $this->parseYamls($configFiles); // connect routes $routes = sfRouting::getInstance(); foreach ($config as $name => $params) { $routes->connect( $name, ($params['url'] ? $params['url'] : '/'), (isset($params['param']) ? $params['param'] : array()), (isset($params['requirements']) ? $params['requirements'] : array()) ); } // compile data $retval = sprintf("setRoutes(\n%s\n);\n", date('Y/m/d H:i:s'), var_export($routes->getRoutes(), 1)); return $retval; } }