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