Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactored routing management (it's now possible to disable the defau…
…lt routing) * removed the Kernel::registerRoutes() method * added a router entry in <web:config> (replaces the registerRoutes() method) <web:config> <web:router resource="%kernel.root_dir%/config/routing.xml" /> </web:config> * refactored routing configuration in its own routing.xml file (leverages the new routing component API), which is loaded only if <web:router> is defined in the configuration
- Loading branch information
Showing
10 changed files
with
140 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<container xmlns="http://www.symfony-project.org/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.symfony-project.org/schema/dic/services http://www.symfony-project.org/schema/dic/services/services-1.0.xsd"> | ||
|
||
<parameters> | ||
<parameter key="router.class">Symfony\Components\Routing\Router</parameter> | ||
<parameter key="routing.loader.class">Symfony\Components\Routing\Loader\DelegatingLoader</parameter> | ||
<parameter key="routing.resolver.class">Symfony\Bundle\FrameworkBundle\Routing\LoaderResolver</parameter> | ||
<parameter key="routing.loader.xml.class">Symfony\Components\Routing\Loader\XmlFileLoader</parameter> | ||
<parameter key="routing.loader.yml.class">Symfony\Components\Routing\Loader\YamlFileLoader</parameter> | ||
<parameter key="routing.loader.php.class">Symfony\Components\Routing\Loader\PhpFileLoader</parameter> | ||
</parameters> | ||
|
||
<services> | ||
<service id="routing.resolver" class="%routing.resolver.class%"> | ||
<argument type="service" id="service_container" /> | ||
</service> | ||
|
||
<service id="routing.loader.xml" class="%routing.loader.xml.class%"> | ||
<annotation name="routing.loader" /> | ||
<argument>%kernel.bundle_dirs%</argument> | ||
</service> | ||
|
||
<service id="routing.loader.yml" class="%routing.loader.yml.class%"> | ||
<annotation name="routing.loader" /> | ||
<argument>%kernel.bundle_dirs%</argument> | ||
</service> | ||
|
||
<service id="routing.loader.php" class="%routing.loader.php.class%"> | ||
<annotation name="routing.loader" /> | ||
<argument>%kernel.bundle_dirs%</argument> | ||
</service> | ||
|
||
<service id="routing.loader" class="%routing.loader.class%"> | ||
<argument type="service" id="routing.resolver" /> | ||
</service> | ||
|
||
<service id="router" class="%router.class%"> | ||
<argument type="service" id="routing.loader" /> | ||
<argument>%routing.resource%</argument> | ||
<argument type="collection"> | ||
<argument key="cache_dir">%kernel.cache_dir%</argument> | ||
<argument key="debug">%kernel.debug%</argument> | ||
<argument key="matcher_cache_class">%kernel.name%UrlMatcher</argument> | ||
<argument key="generator_cache_class">%kernel.name%UrlGenerator</argument> | ||
</argument> | ||
</service> | ||
</services> | ||
</container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/Symfony/Bundle/FrameworkBundle/Routing/LoaderResolver.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Routing; | ||
|
||
use Symfony\Components\Routing\Loader\LoaderResolver as BaseLoaderResolver; | ||
use Symfony\Components\DependencyInjection\ContainerInterface; | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
/** | ||
* This loader resolver automatically registers routing loaders from | ||
* the container. | ||
* | ||
* If also lazy-loads them. | ||
* | ||
* @package Symfony | ||
* @subpackage Bundle_FrameworkBundle | ||
* @author Fabien Potencier <fabien.potencier@symfony-project.com> | ||
*/ | ||
class LoaderResolver extends BaseLoaderResolver | ||
{ | ||
protected $services; | ||
protected $container; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param \Symfony\Components\DependencyInjection\ContainerInterface $container A ContainerInterface instance | ||
* @param \Symfony\Components\Routing\Loader\LoaderInterface[] $loaders An array of loaders | ||
*/ | ||
public function __construct(ContainerInterface $container, array $loaders = array()) | ||
{ | ||
parent::__construct($loaders); | ||
|
||
$this->container = $container; | ||
foreach ($container->findAnnotatedServiceIds('routing.loader') as $id => $attributes) { | ||
$this->services[] = $id; | ||
} | ||
} | ||
|
||
/** | ||
* Returns a loader able to load the resource. | ||
* | ||
* @param mixed $resource A resource | ||
* | ||
* @return Symfony\Components\Routing\Loader\LoaderInterface A LoaderInterface instance | ||
*/ | ||
public function resolve($resource) | ||
{ | ||
if (count($this->services)) { | ||
while ($id = array_shift($this->services)) { | ||
$this->addLoader($this->container->get($id)); | ||
} | ||
} | ||
|
||
return parent::resolve($resource); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters