1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Setono\SyliusStockMovementPlugin\DependencyInjection; |
||
6 | |||
7 | use Exception; |
||
8 | use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension; |
||
9 | use Symfony\Component\Config\FileLocator; |
||
10 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
||
11 | use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; |
||
12 | |||
13 | final class SetonoSyliusStockMovementExtension extends AbstractResourceExtension |
||
14 | { |
||
15 | /** |
||
16 | * {@inheritdoc} |
||
17 | * |
||
18 | * @throws Exception |
||
19 | */ |
||
20 | public function load(array $config, ContainerBuilder $container): void |
||
21 | { |
||
22 | $config = $this->processConfiguration($this->getConfiguration([], $container), $config); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
23 | $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
||
24 | |||
25 | $container->setParameter('setono_sylius_stock_movement.filesystem.report', $config['report_filesystem']); |
||
26 | |||
27 | $this->registerTemplateParameter($container, $config['templates']); |
||
28 | |||
29 | $loader->load('services.xml'); |
||
30 | |||
31 | $this->registerResources('setono_sylius_stock_movement', $config['driver'], $config['resources'], $container); |
||
32 | } |
||
33 | |||
34 | private function registerTemplateParameter(ContainerBuilder $container, array $templates): void |
||
35 | { |
||
36 | $res = []; |
||
37 | |||
38 | foreach ($templates as $template => $item) { |
||
39 | $res[$template] = $item['label']; |
||
40 | } |
||
41 | $container->setParameter('setono_sylius_stock_movement.templates', $res); |
||
42 | } |
||
43 | } |
||
44 |