1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Victoire\Bundle\I18nBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\FileLocator; |
6
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
7
|
|
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
8
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
9
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* This is the class that loads and manages your bundle configuration. |
13
|
|
|
* |
14
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} |
15
|
|
|
*/ |
16
|
|
|
class VictoireI18nExtension extends Extension implements PrependExtensionInterface |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* {@inheritdoc} |
20
|
|
|
*/ |
21
|
|
|
public function load(array $configs, ContainerBuilder $container) |
22
|
|
|
{ |
23
|
|
|
$configuration = new Configuration(); |
24
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
25
|
|
|
|
26
|
|
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
27
|
|
|
$loader->load('services.yml'); |
28
|
|
|
|
29
|
|
|
$container->setParameter( |
30
|
|
|
'victoire_i18n.available_locales', $config['available_locales'] |
31
|
|
|
); |
32
|
|
|
$container->setParameter( |
33
|
|
|
'victoire_i18n.locale_pattern_table', $config['locale_pattern_table'] |
34
|
|
|
); |
35
|
|
|
$container->setParameter( |
36
|
|
|
'victoire_i18n.victoire_locale', $config['victoire_locale'] |
37
|
|
|
); |
38
|
|
|
$container->setParameter( |
39
|
|
|
'victoire_i18n.users_locale.domains', $config['users_locale_domains'] |
40
|
|
|
); |
41
|
|
|
$container->setParameter( |
42
|
|
|
'victoire_i18n.locale_pattern', $config['locale_pattern'] |
43
|
|
|
); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function prepend(ContainerBuilder $container) |
|
|
|
|
47
|
|
|
{ |
48
|
|
|
$config = $container->getExtensionConfig($this->getAlias()); |
49
|
|
|
$config = $container->getParameterBag()->resolveValue($config); |
50
|
|
|
|
51
|
|
|
$config = $this->processConfiguration(new Configuration(), $config); |
52
|
|
|
|
53
|
|
|
if (isset($config['available_locales'])) { |
54
|
|
|
$container->prependExtensionConfig('a2lix_translation_form', [ |
55
|
|
|
'locales' => $config['available_locales'], |
56
|
|
|
]); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|