1 | <?php |
||
25 | class OrbitaleCmsExtension extends Extension |
||
26 | { |
||
27 | /** |
||
28 | * {@inheritdoc} |
||
29 | */ |
||
30 | public function load(array $configs, ContainerBuilder $container) |
||
31 | { |
||
32 | $configuration = new Configuration(); |
||
33 | $config = $this->processConfiguration($configuration, $configs); |
||
34 | |||
35 | foreach ($config['layouts'] as $name => $layout) { |
||
36 | $config['layouts'][$name] = array_merge(array( |
||
37 | 'name' => $name, |
||
38 | 'assets_css' => '', |
||
39 | 'assets_js' => '', |
||
40 | 'host' => '', |
||
41 | 'pattern' => '', |
||
42 | ), $layout); |
||
43 | if (!$config['layouts'][$name]['host'] && !$config['layouts'][$name]['pattern']) { |
||
44 | // If the user does not specify anything in the host nor the pattern, |
||
45 | // we force the pattern to match at least the root, else the layout would never be used... |
||
46 | $config['layouts'][$name]['pattern'] = '^/'; |
||
47 | } |
||
48 | } |
||
49 | |||
50 | // Sort configs by host, because host is checked before pattern. |
||
51 | uasort($config['layouts'], function($a, $b) { |
||
52 | if ($a['host'] && $b['host']) { |
||
53 | return strcasecmp($a['host'], $b['host']); |
||
54 | } elseif ($a['host'] && !$b['host']) { |
||
55 | return -1; |
||
56 | } else { |
||
57 | return 1; |
||
58 | } |
||
59 | }); |
||
60 | |||
61 | $container->setParameter('orbitale_cms.config', $config); |
||
62 | |||
63 | $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
||
64 | $loader->load('services.yml'); |
||
65 | if ($this->isSymfony3()) { |
||
66 | $loader->load('services_3.yml'); |
||
67 | } else { |
||
68 | $loader->load('services_2.yml'); |
||
69 | } |
||
70 | } |
||
71 | |||
72 | protected function isSymfony3() |
||
76 | } |
||
77 |