|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace BitBag\SyliusElasticsearchPlugin\DependencyInjection; |
|
6
|
|
|
|
|
7
|
|
|
use Symfony\Component\Config\FileLocator; |
|
8
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
9
|
|
|
use Symfony\Component\DependencyInjection\Extension\Extension; |
|
10
|
|
|
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; |
|
11
|
|
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; |
|
12
|
|
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
|
13
|
|
|
|
|
14
|
|
|
final class BitBagSyliusElasticsearchExtension extends Extension implements PrependExtensionInterface |
|
15
|
|
|
{ |
|
16
|
|
|
public function load(array $config, ContainerBuilder $container): void |
|
17
|
|
|
{ |
|
18
|
|
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
|
19
|
|
|
|
|
20
|
|
|
$loader->load('services.xml'); |
|
21
|
|
|
|
|
22
|
|
|
$configuration = new Configuration(); |
|
23
|
|
|
|
|
24
|
|
|
$config = $this->processConfiguration($configuration, $config); |
|
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function prepend(ContainerBuilder $container) |
|
29
|
|
|
{ |
|
30
|
|
|
// dump("je passe dans preprend"); |
|
31
|
|
|
$configs = $container->getExtensionConfig($this->getAlias()); |
|
32
|
|
|
$config = $this->processConfiguration(new Configuration(), $configs); |
|
33
|
|
|
$container->setParameter('bitbag_es_filter_attributes_max', $config['filter_attributes_max']); |
|
34
|
|
|
$container->setParameter('bitbag_es_filter_options_max', $config['filter_options_max']); |
|
35
|
|
|
$container->setParameter('bitbag_es_shop_name_property_prefix', $config['shop_name_property_prefix']); |
|
36
|
|
|
$container->setParameter('bitbag_es_excluded_filter_options', $config['excluded_filter']['options']); |
|
37
|
|
|
$container->setParameter('bitbag_es_excluded_filter_attributes', $config['excluded_filter']['attributes']); |
|
38
|
|
|
dump($configs); |
|
39
|
|
|
dump($config); |
|
40
|
|
|
//$container = prependExtensionConfig($name, $config); |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
|