1 | <?php |
||
26 | class SWPUpdaterExtension extends Extension |
||
27 | { |
||
28 | private $container; |
||
29 | |||
30 | /** |
||
31 | * {@inheritdoc} |
||
32 | */ |
||
33 | public function load(array $configs, ContainerBuilder $container) |
||
34 | { |
||
35 | $this->container = $container; |
||
36 | $config = $this->processConfiguration(new Configuration(), $configs); |
||
37 | $loader = new Loader\YamlFileLoader($this->container, new FileLocator(__DIR__.'/../Resources/config')); |
||
38 | $loader->load('services.yml'); |
||
39 | |||
40 | $this->checkAndSetSupportedClass($config); |
||
41 | |||
42 | $clientConfig = array(); |
||
43 | if (!empty($config['client'])) { |
||
44 | foreach (array('base_uri') as $key) { |
||
45 | $clientConfig[$key] = $config['client'][$key]; |
||
46 | } |
||
47 | |||
48 | $this->container->setParameter($this->getAlias().'.client', $clientConfig); |
||
49 | } |
||
50 | |||
51 | $options = array(); |
||
52 | if ($this->container->hasParameter($this->getAlias().'.client.options')) { |
||
53 | $options = $this->container->getParameter($this->getAlias().'.client.options'); |
||
54 | } |
||
55 | |||
56 | $this->container->setParameter($this->getAlias().'.client.options', $options); |
||
57 | |||
58 | if (!empty($config['version_class'])) { |
||
59 | $this->container->setParameter($this->getAlias().'.version_class', $config['version_class']); |
||
60 | } |
||
61 | |||
62 | $this->setDirectories($config); |
||
63 | |||
64 | if (true === $config['monolog_channel']) { |
||
65 | $this->container->setParameter($this->getAlias().'.monolog_channel', true); |
||
66 | } |
||
67 | } |
||
68 | |||
69 | private function checkAndSetSupportedClass(array $config) |
||
87 | |||
88 | private function setDirectories($config) |
||
104 | |||
105 | private function checkDirType($dir) |
||
113 | |||
114 | private function checkNotDefaultDirType($dir, $configDir) |
||
122 | |||
123 | private function isDefault($dir) |
||
131 | } |
||
132 |