| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Actualys\Bundle\DrupalCommerceConnectorBundle\DependencyInjection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Symfony\Component\DependencyInjection\ContainerBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Symfony\Component\Config\FileLocator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Symfony\Component\DependencyInjection\Definition; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Symfony\Component\HttpKernel\DependencyInjection\Extension; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Symfony\Component\DependencyInjection\Loader; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 ActualysDrupalCommerceConnectorExtension extends Extension | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      * @param array            $configs | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      * @param ContainerBuilder $container | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 22 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 23 |  |  |     public function load(array $configs, ContainerBuilder $container) | 
            
                                                        
            
                                    
            
            
                | 24 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 25 |  |  |         $configuration = new Configuration(); | 
            
                                                        
            
                                    
            
            
                | 26 |  |  |         $this->processConfiguration($configuration, $configs); | 
            
                                                        
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 28 |  |  |         $loader = new Loader\YamlFileLoader( | 
            
                                                        
            
                                    
            
            
                | 29 |  |  |           $container, | 
            
                                                        
            
                                    
            
            
                | 30 |  |  |           new FileLocator(__DIR__.'/../Resources/config') | 
            
                                                        
            
                                    
            
            
                | 31 |  |  |         ); | 
            
                                                        
            
                                    
            
            
                | 32 |  |  |         $loader->load('services.yml'); | 
            
                                                        
            
                                    
            
            
                | 33 |  |  |         $loader->load('normalizers.yml'); | 
            
                                                        
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 35 |  |  |         $loader->load('readers.yml'); | 
            
                                                        
            
                                    
            
            
                | 36 |  |  |         $loader->load('processors.yml'); | 
            
                                                        
            
                                    
            
            
                | 37 |  |  |         $loader->load('writers.yml'); | 
            
                                                        
            
                                    
            
            
                | 38 |  |  |         $loader->load('managers.yml'); | 
            
                                                        
            
                                    
            
            
                | 39 |  |  |      //   $loader->load('validation.yml'); | 
            
                                                        
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 41 |  |  |         if (!$container->hasDefinition( | 
            
                                                        
            
                                    
            
            
                | 42 |  |  |           'actualys_drupal_commerce_connector.normalizers' | 
            
                                                        
            
                                    
            
            
                | 43 |  |  |         ) | 
            
                                                        
            
                                    
            
            
                | 44 |  |  |         ) { | 
            
                                                        
            
                                    
            
            
                | 45 |  |  |             $taggedServiceHolder = new Definition(); | 
            
                                                        
            
                                    
            
            
                | 46 |  |  |             $taggedServiceHolder->setClass( | 
            
                                                        
            
                                    
            
            
                | 47 |  |  |               'Actualys\Bundle\DrupalCommerceConnectorBundle\DependencyInjection\Compiler\AggregatedTaggedNormalizer' | 
            
                                                        
            
                                    
            
            
                | 48 |  |  |             ); | 
            
                                                        
            
                                    
            
            
                | 49 |  |  |             $container->setDefinition( | 
            
                                                        
            
                                    
            
            
                | 50 |  |  |               'actualys_drupal_commerce_connector.normalizers', | 
            
                                                        
            
                                    
            
            
                | 51 |  |  |               $taggedServiceHolder | 
            
                                                        
            
                                    
            
            
                | 52 |  |  |             ); | 
            
                                                        
            
                                    
            
            
                | 53 |  |  |         } | 
            
                                                        
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 55 |  |  |         if (in_array( | 
            
                                                        
            
                                    
            
            
                | 56 |  |  |             'PimEnterprise\Bundle\CatalogBundle\PimEnterpriseCatalogBundle', | 
            
                                                        
            
                                    
            
            
                | 57 |  |  |             $container->getParameter('kernel.bundles')) | 
            
                                                        
            
                                    
            
            
                | 58 |  |  |         ) { | 
            
                                                        
            
                                    
            
            
                | 59 |  |  |             $loader->load('pimee_readers.yml'); | 
            
                                                        
            
                                    
            
            
                | 60 |  |  |         } | 
            
                                                        
            
                                    
            
            
                | 61 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 62 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 63 |  |  |  |