1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Tadcka package. |
5
|
|
|
* |
6
|
|
|
* (c) Tadas Gliaubicas <[email protected]> |
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 Tadcka\Bundle\RoutingBundle; |
13
|
|
|
|
14
|
|
|
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass; |
15
|
|
|
use Symfony\Cmf\Component\Routing\DependencyInjection\Compiler\RegisterRouteEnhancersPass; |
16
|
|
|
use Symfony\Cmf\Component\Routing\DependencyInjection\Compiler\RegisterRoutersPass; |
17
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
18
|
|
|
use Symfony\Component\HttpKernel\Bundle\Bundle; |
19
|
|
|
use Tadcka\Bundle\RoutingBundle\DependencyInjection\Compiler\ChainRouterPass; |
20
|
|
|
use Tadcka\Bundle\RoutingBundle\DependencyInjection\Compiler\DynamicRouterPass; |
21
|
|
|
use Tadcka\Bundle\RoutingBundle\DependencyInjection\Compiler\SymfonyRouterPass; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @author Tadas Gliaubicas <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
class TadckaRoutingBundle extends Bundle |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* {@inheritdoc} |
30
|
|
|
*/ |
31
|
|
|
public function build(ContainerBuilder $container) |
32
|
|
|
{ |
33
|
|
|
parent::build($container); |
34
|
|
|
|
35
|
|
|
$container->addCompilerPass(new SymfonyRouterPass()); |
36
|
|
|
$container->addCompilerPass(new DynamicRouterPass()); |
37
|
|
|
$container->addCompilerPass(new ChainRouterPass()); |
38
|
|
|
$container->addCompilerPass(new RegisterRoutersPass('tadcka_routing.chain_router')); |
39
|
|
|
$container->addCompilerPass(new RegisterRouteEnhancersPass('tadcka_routing.dynamic_router')); |
40
|
|
|
|
41
|
|
|
$this->addRegisterMappingsPass($container); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Add register mappings pass. |
46
|
|
|
* |
47
|
|
|
* @param ContainerBuilder $container |
48
|
|
|
*/ |
49
|
|
|
private function addRegisterMappingsPass(ContainerBuilder $container) |
50
|
|
|
{ |
51
|
|
|
$mappings = array( |
52
|
|
|
realpath(__DIR__ . '/Resources/config/doctrine/base') => 'Symfony\Component\Routing', |
53
|
|
|
realpath(__DIR__ . '/Resources/config/doctrine/model') => 'Tadcka\Component\Routing\Model', |
54
|
|
|
); |
55
|
|
|
|
56
|
|
|
$ormCompilerClass = 'Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass'; |
57
|
|
|
if (class_exists($ormCompilerClass)) { |
58
|
|
|
$container->addCompilerPass(DoctrineOrmMappingsPass::createXmlMappingDriver($mappings)); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|