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
|
|
|
|
10
|
|
|
class RjFrontendExtension extends Extension |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* {@inheritdoc} |
14
|
|
|
*/ |
15
|
20 |
|
public function load(array $configs, ContainerBuilder $container) |
16
|
|
|
{ |
17
|
20 |
|
$configuration = $this->getConfiguration([], $container); |
18
|
20 |
|
$config = $this->processConfiguration($configuration, $configs); |
19
|
|
|
|
20
|
20 |
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/')); |
21
|
20 |
|
$loader->load('console.yml'); |
22
|
20 |
|
$loader->load('version_strategy.yml'); |
23
|
20 |
|
$loader->load('manifest.yml'); |
24
|
|
|
|
25
|
20 |
|
if ($config['livereload']['enabled']) { |
26
|
18 |
|
$loader->load('livereload.yml'); |
27
|
18 |
|
$container->getDefinition($this->namespaceService('livereload.listener')) |
28
|
18 |
|
->addArgument($config['livereload']['url']); |
29
|
|
|
} |
30
|
|
|
|
31
|
20 |
|
$assetExtensionLoader = new AssetExtensionLoader($this->getAlias(), $container); |
32
|
20 |
|
$assetExtensionLoader->load($config, $loader); |
33
|
20 |
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param array $config |
37
|
|
|
* @param ContainerBuilder $container |
38
|
|
|
* |
39
|
|
|
* @return Configuration |
40
|
|
|
*/ |
41
|
20 |
|
public function getConfiguration(array $config, ContainerBuilder $container) |
42
|
|
|
{ |
43
|
20 |
|
return new Configuration($container->getParameter('kernel.root_dir')); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param string $id |
48
|
|
|
* |
49
|
|
|
* @return string |
50
|
|
|
*/ |
51
|
18 |
|
private function namespaceService($id) |
52
|
|
|
{ |
53
|
18 |
|
return $this->getAlias().'.'.$id; |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|