1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Rj\FrontendBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
6
|
|
|
use Symfony\Component\Config\FileLocator; |
7
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
8
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
9
|
|
|
use Symfony\Component\HttpKernel\Kernel; |
10
|
|
|
|
11
|
|
|
class RjFrontendExtension extends Extension |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* {@inheritdoc} |
15
|
|
|
*/ |
16
|
20 |
|
public function load(array $configs, ContainerBuilder $container) |
17
|
|
|
{ |
18
|
20 |
|
$configuration = $this->getConfiguration([], $container); |
19
|
20 |
|
$config = $this->processConfiguration($configuration, $configs); |
20
|
|
|
|
21
|
20 |
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/')); |
22
|
20 |
|
$loader->load('console.yml'); |
23
|
20 |
|
$loader->load('version_strategy.yml'); |
24
|
20 |
|
$loader->load('manifest.yml'); |
25
|
|
|
|
26
|
20 |
|
if (version_compare(Kernel::VERSION, '3.3.0', '>=')) { |
27
|
20 |
|
$loader->load('commands.yml'); |
28
|
|
|
} |
29
|
|
|
|
30
|
20 |
|
if ($config['livereload']['enabled']) { |
31
|
18 |
|
$loader->load('livereload.yml'); |
32
|
18 |
|
$container->getDefinition($this->namespaceService('livereload.listener')) |
33
|
18 |
|
->addArgument($config['livereload']['url']); |
34
|
|
|
} |
35
|
|
|
|
36
|
20 |
|
$assetExtensionLoader = new AssetExtensionLoader($this->getAlias(), $container); |
37
|
20 |
|
$assetExtensionLoader->load($config, $loader); |
38
|
20 |
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param array $config |
42
|
|
|
* @param ContainerBuilder $container |
43
|
|
|
* |
44
|
|
|
* @return Configuration |
45
|
|
|
*/ |
46
|
20 |
|
public function getConfiguration(array $config, ContainerBuilder $container) |
47
|
|
|
{ |
48
|
20 |
|
return new Configuration($container->getParameter('kernel.root_dir')); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param string $id |
53
|
|
|
* |
54
|
|
|
* @return string |
55
|
|
|
*/ |
56
|
18 |
|
private function namespaceService($id) |
57
|
|
|
{ |
58
|
18 |
|
return $this->getAlias().'.'.$id; |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|