Skip to content

Commit e10bb2c

Browse files
committed
Adding a ServiceRouterLoader that works with the DependencyInjection component
1 parent b3d62fb commit e10bb2c

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<argument type="service" id="file_locator" />
5151
</service>
5252

53-
<service id="routing.loader.service" class="Symfony\Component\Routing\Loader\ServiceRouterLoader" public="false">
53+
<service id="routing.loader.service" class="Symfony\Component\Routing\Loader\DependencyInjection\ServiceRouterLoader" public="false">
5454
<tag name="routing.loader" />
5555
<argument type="service" id="service_container" />
5656
</service>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Routing\Loader\DependencyInjection;
13+
14+
use Symfony\Component\Config\Loader\Loader;
15+
use Symfony\Component\Config\Resource\FileResource;
16+
use Symfony\Component\DependencyInjection\ContainerInterface;
17+
use Symfony\Component\Routing\Loader\ObjectRouteLoader;
18+
use Symfony\Component\Routing\Loader\RouteLoaderInterface;
19+
use Symfony\Component\Routing\RouteCollection;
20+
21+
/**
22+
* A route loader that executes a service to load the routes.
23+
*
24+
* This depends on the DependencyInjection component.
25+
*
26+
* @author Ryan Weaver <ryan@knpuniversity.com>
27+
*/
28+
class ServiceRouterLoader extends ObjectRouteLoader
29+
{
30+
/**
31+
* @var ContainerInterface
32+
*/
33+
private $container;
34+
35+
public function __construct(ContainerInterface $container)
36+
{
37+
$this->container = $container;
38+
}
39+
40+
protected function getRouteLoader($id)
41+
{
42+
return $this->container->get($id);
43+
}
44+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy