Development

/branches/1.0/lib/config/sfRoutingConfigHandler.class.php

You must first sign up to be able to contribute.

root/branches/1.0/lib/config/sfRoutingConfigHandler.class.php

Revision 3203, 1.6 kB (checked in by fabien, 8 years ago)
  • added phpdoc to the config/ files
  • renamed sfLoader::getConfigDirs() to sfLoader::getConfigPaths()
  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Rev Date
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * @package    symfony
13  * @subpackage config
14  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
15  * @version    SVN: $Id$
16  */
17 class sfRoutingConfigHandler extends sfYamlConfigHandler
18 {
19   /**
20    * Executes this configuration handler.
21    *
22    * @param array An array of absolute filesystem path to a configuration file
23    *
24    * @return string Data to be written to a cache file
25    *
26    * @throws sfConfigurationException If a requested configuration file does not exist or is not readable
27    * @throws sfParseException If a requested configuration file is improperly formatted
28    */
29   public function execute($configFiles)
30   {
31     // parse the yaml
32     $config = $this->parseYamls($configFiles);
33
34     // connect routes
35     $routes = sfRouting::getInstance();
36     foreach ($config as $name => $params)
37     {
38       $routes->connect(
39         $name,
40         ($params['url'] ? $params['url'] : '/'),
41         (isset($params['param']) ? $params['param'] : array()),
42         (isset($params['requirements']) ? $params['requirements'] : array())
43       );
44     }
45
46     // compile data
47     $retval = sprintf("<?php\n".
48                       "// auto-generated by sfRoutingConfigHandler\n".
49                       "// date: %s\n\$routes = sfRouting::getInstance();\n\$routes->setRoutes(\n%s\n);\n",
50                       date('Y/m/d H:i:s'), var_export($routes->getRoutes(), 1));
51
52     return $retval;
53   }
54 }
55
Note: See TracBrowser for help on using the browser.