|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
namespace Sensio\Bundle\FrameworkExtraBundle\DependencyInjection; |
|
|
4 |
|
|
|
5 |
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
|
6 |
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; |
|
|
7 |
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
|
8 |
use Symfony\Component\DependencyInjection\Reference; |
|
|
9 |
use Symfony\Component\DependencyInjection\Definition; |
|
|
10 |
use Symfony\Component\Config\FileLocator; |
|
|
11 |
use Symfony\Component\Config\Resource\FileResource; |
|
|
12 |
use Symfony\Component\Config\Definition\Processor; |
|
|
13 |
|
|
|
14 |
/* |
|
|
15 |
* This file is part of the Symfony framework. |
|
|
16 |
* |
|
|
17 |
* (c) Fabien Potencier <fabien@symfony.com> |
|
|
18 |
* |
|
|
19 |
* This source file is subject to the MIT license that is bundled |
|
|
20 |
* with this source code in the file LICENSE. |
|
|
21 |
*/ |
|
|
22 |
|
|
|
23 |
/** |
|
|
24 |
* SensioFrameworkExtraExtension. |
|
|
25 |
* |
|
|
26 |
* @author Fabien Potencier <fabien@symfony.com> |
|
|
27 |
*/ |
|
|
28 |
class SensioFrameworkExtraExtension extends Extension |
|
|
29 |
{ |
|
|
30 |
public function load(array $configs, ContainerBuilder $container) |
|
|
31 |
{ |
|
|
32 |
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
|
33 |
|
|
|
34 |
$processor = new Processor(); |
|
|
35 |
$configuration = new Configuration(); |
|
|
36 |
|
|
|
37 |
$config = $processor->process($configuration->getConfigTree(), $configs); |
|
|
38 |
|
|
|
39 |
$annotationsToLoad = array(); |
|
|
40 |
|
|
|
41 |
if ($config['router']['annotations']) { |
|
|
42 |
$annotationsToLoad[] = 'routing.xml'; |
|
|
43 |
} |
|
|
44 |
|
|
|
45 |
if ($config['request']['converters']) { |
|
|
46 |
$annotationsToLoad[] = 'converters.xml'; |
|
|
47 |
} |
|
|
48 |
|
|
|
49 |
if ($config['view']['annotations']) { |
|
|
50 |
$annotationsToLoad[] = 'view.xml'; |
|
|
51 |
} |
|
|
52 |
|
|
|
53 |
if ($config['cache']['annotations']) { |
|
|
54 |
$annotationsToLoad[] = 'cache.xml'; |
|
|
55 |
} |
|
|
56 |
|
|
|
57 |
if ($annotationsToLoad) { |
|
|
58 |
// must be first |
|
|
59 |
$loader->load('annotations.xml'); |
|
|
60 |
|
|
|
61 |
foreach ($annotationsToLoad as $config) { |
|
|
62 |
$loader->load($config); |
|
|
63 |
} |
|
|
64 |
} |
|
|
65 |
} |
|
|
66 |
|
|
|
67 |
/** |
|
|
68 |
* Returns the base path for the XSD files. |
|
|
69 |
* |
|
|
70 |
* @return string The XSD base path |
|
|
71 |
*/ |
|
|
72 |
public function getXsdValidationBasePath() |
|
|
73 |
{ |
|
|
74 |
return __DIR__.'/../Resources/config/schema'; |
|
|
75 |
} |
|
|
76 |
|
|
|
77 |
public function getNamespace() |
|
|
78 |
{ |
|
|
79 |
return 'http://symfony.com/schema/dic/symfony_extra'; |
|
|
80 |
} |
|
|
81 |
} |