|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GBProd\ElasticaExtraBundle\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use GBProd\ElasticaExtraBundle\Repository\IndexConfigurationRepository; |
|
6
|
|
|
use Symfony\Component\Config\FileLocator; |
|
7
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
8
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
|
9
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
10
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Extension class for ElasticsearchExtra bundle |
|
14
|
|
|
* |
|
15
|
|
|
* @author gbprod <[email protected]> |
|
16
|
|
|
*/ |
|
17
|
|
|
class ElasticaExtraExtension extends Extension |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* {@inheritdoc} |
|
21
|
|
|
*/ |
|
22
|
10 |
|
public function load(array $configs, ContainerBuilder $container) |
|
23
|
|
|
{ |
|
24
|
10 |
|
$configuration = new Configuration(); |
|
25
|
10 |
|
$config = $this->processConfiguration($configuration, $configs); |
|
26
|
|
|
|
|
27
|
10 |
|
$this->createIndexConfigurationRepository($config, $container); |
|
28
|
|
|
|
|
29
|
10 |
|
if (null !== $config['default_client']) { |
|
30
|
1 |
|
$container->setAlias( |
|
31
|
1 |
|
'gbprod.elastica_extra.default_client', |
|
32
|
1 |
|
$config['default_client'] |
|
33
|
1 |
|
); |
|
34
|
1 |
|
} |
|
35
|
|
|
|
|
36
|
10 |
|
$loader = new Loader\YamlFileLoader( |
|
37
|
10 |
|
$container, |
|
38
|
10 |
|
new FileLocator(__DIR__.'/../Resources/config') |
|
39
|
10 |
|
); |
|
40
|
|
|
|
|
41
|
10 |
|
$loader->load('services.yml'); |
|
42
|
10 |
|
} |
|
43
|
|
|
|
|
44
|
10 |
|
private function createIndexConfigurationRepository(array $config, ContainerBuilder $container) |
|
45
|
|
|
{ |
|
46
|
|
|
$container |
|
47
|
10 |
|
->register( |
|
48
|
10 |
|
'gbprod.elastica_extra.index_configuration_repository', |
|
49
|
|
|
IndexConfigurationRepository::class |
|
50
|
10 |
|
) |
|
51
|
10 |
|
->addArgument($config['indices']) |
|
52
|
|
|
; |
|
53
|
10 |
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|