|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the ONGR package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) NFQ Technologies UAB <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace ONGR\TranslationsBundle\DependencyInjection; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; |
|
15
|
|
|
use Symfony\Component\Config\FileLocator; |
|
16
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
17
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
|
18
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
|
19
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
20
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* This is the class that loads and manages bundle configuration. |
|
24
|
|
|
*/ |
|
25
|
|
|
class ONGRTranslationsExtension extends Extension |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* {@inheritdoc} |
|
29
|
|
|
*/ |
|
30
|
2 |
|
public function load(array $configs, ContainerBuilder $container) |
|
31
|
|
|
{ |
|
32
|
2 |
|
$configuration = new Configuration(); |
|
33
|
2 |
|
$config = $this->processConfiguration($configuration, $configs); |
|
34
|
|
|
|
|
35
|
2 |
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
|
36
|
2 |
|
$loader->load('services.yml'); |
|
37
|
2 |
|
$loader->load('filters_container.yml'); |
|
38
|
|
|
|
|
39
|
2 |
|
$container->setParameter('ongr_translations.locales', $config['locales']); |
|
40
|
2 |
|
$container->setParameter('ongr_translations.list_size', $config['list_size']); |
|
41
|
2 |
|
$container->setParameter('ongr_translations.bundles', $config['bundles']); |
|
42
|
2 |
|
$container->setAlias('ongr_translations.repository.translation', $config['repository']['translation']); |
|
43
|
|
|
$container->setAlias('ongr_translations.repository.history', $config['repository']['history']); |
|
44
|
1 |
|
|
|
45
|
1 |
|
$this->setFiltersManager($config['repository']['translation'], $container); |
|
46
|
1 |
|
} |
|
47
|
1 |
|
|
|
48
|
1 |
|
/** |
|
49
|
1 |
|
* Adds filter manager for displaying translations gui. |
|
50
|
1 |
|
* |
|
51
|
|
|
* @param string $repository Elasticsearch repository id. |
|
52
|
1 |
|
* @param ContainerBuilder $container Service container. |
|
53
|
|
|
*/ |
|
54
|
|
|
private function setFiltersManager($repository, ContainerBuilder $container) |
|
55
|
|
|
{ |
|
56
|
|
|
$definition = new Definition( |
|
57
|
|
|
'ONGR\FilterManagerBundle\Search\FilterManager', |
|
58
|
|
|
[ |
|
59
|
|
|
new Reference('ongr_translations.filters_container'), |
|
60
|
1 |
|
new Reference($repository), |
|
61
|
|
|
new Reference('event_dispatcher'), |
|
62
|
1 |
|
new Reference('jms_serializer') |
|
63
|
1 |
|
] |
|
64
|
|
|
); |
|
65
|
1 |
|
|
|
66
|
1 |
|
$container->setDefinition('ongr_translations.filter_manager', $definition); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|