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\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
15
|
|
|
use Symfony\Component\Config\FileLocator; |
16
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
17
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @author Tadas Gliaubicas <[email protected]> |
21
|
|
|
* |
22
|
|
|
* @since 7/1/14 11:09 PM |
23
|
|
|
*/ |
24
|
|
|
class TadckaRoutingExtension extends Extension |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* {@inheritDoc} |
28
|
|
|
*/ |
29
|
|
|
public function load(array $configs, ContainerBuilder $container) |
30
|
|
|
{ |
31
|
|
|
$configuration = new Configuration(); |
32
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
33
|
|
|
|
34
|
|
|
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
35
|
|
|
$loader->load('chain-router.xml'); |
36
|
|
|
$loader->load('controllers.xml'); |
37
|
|
|
$loader->load('dynamic-router.xml'); |
38
|
|
|
$loader->load('form/redirect-route.xml'); |
39
|
|
|
$loader->load('form/route.xml'); |
40
|
|
|
$loader->load('form/route-choice.xml'); |
41
|
|
|
$loader->load('helpers.xml'); |
42
|
|
|
$loader->load('services.xml'); |
43
|
|
|
|
44
|
|
|
if (!in_array(strtolower($config['db_driver']), array('mongodb', 'orm'))) { |
45
|
|
|
throw new \InvalidArgumentException(sprintf('Invalid db driver "%s".', $config['db_driver'])); |
46
|
|
|
} |
47
|
|
|
$loader->load('db_driver/' . sprintf('%s.xml', $config['db_driver'])); |
48
|
|
|
|
49
|
|
|
$container->setParameter($this->getAlias() . '.model.route.class', $config['class']['model']['route']); |
50
|
|
|
$container->setParameter( |
51
|
|
|
$this->getAlias() . '.model.redirect_route.class', |
52
|
|
|
$config['class']['model']['redirect_route'] |
53
|
|
|
); |
54
|
|
|
|
55
|
|
|
$container->setAlias($this->getAlias() . '.manager.route', $config['route_manager']); |
56
|
|
|
$container->setAlias($this->getAlias() . '.manager.redirect_route', $config['redirect_route_manager']); |
57
|
|
|
|
58
|
|
|
$container->setParameter($this->getAlias() . '.chain_router.enabled', $config['chain_router']['enabled']); |
59
|
|
|
$container->setParameter($this->getAlias() . '.dynamic_router.priority', $config['dynamic_router']['priority']); |
60
|
|
|
$container->setParameter($this->getAlias() . '.router.priority', $config['router']['priority']); |
61
|
|
|
|
62
|
|
|
$container->setParameter($this->getAlias() . '.locales', $config['locales']); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|