vendor\project-biz\js-select2-bundle\src\DependencyInjection\ProjectBizJsSelect2Extension.php line 34

Open in your IDE?
  1. <?php
  2. namespace ProjectBiz\JsSelect2Bundle\DependencyInjection;
  3. use Symfony\Component\DependencyInjection\ContainerBuilder;
  4. use Symfony\Component\Config\FileLocator;
  5. use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
  6. use Symfony\Component\HttpKernel\DependencyInjection\Extension;
  7. use Symfony\Component\DependencyInjection\Loader;
  8. /**
  9.  * This is the class that loads and manages your bundle configuration
  10.  *
  11.  * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
  12.  */
  13. class ProjectBizJsSelect2Extension extends Extension implements PrependExtensionInterface
  14. {
  15.     /**
  16.      * {@inheritDoc}
  17.      */
  18.     public function load(array $configsContainerBuilder $container)
  19.     {
  20.         $configuration = new Configuration();
  21.         $this->processConfiguration($configuration$configs);
  22.         $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ '/../Resources/config'));
  23.         $loader->load('services.yml');
  24.     }
  25.     /**
  26.      * {@inheritDoc}
  27.      */
  28.     public function prepend(ContainerBuilder $container)
  29.     {
  30.         $bundles $container->getParameter('kernel.bundles');
  31.         $configs $container->getExtensionConfig($this->getAlias());
  32.         $config  $this->processConfiguration(new Configuration(), $configs);
  33.         // Configure Assetic if AsseticBundle is activated and the option
  34.         // "project_biz_js_select2.auto_configure.assetic" is set to TRUE (default value).
  35.         if (true === isset($bundles['AsseticBundle']) && true === $config['auto_configure']['assetic']) {
  36.             $this->configureAsseticBundle($container$config);
  37.         }
  38.     }
  39.     /**
  40.      * @param ContainerBuilder $container The service container
  41.      * @param array            $config    The bundle configuration
  42.      *
  43.      * @return void
  44.      */
  45.     protected function configureAsseticBundle(ContainerBuilder $container, array $config)
  46.     {
  47.         foreach (array_keys($container->getExtensions()) as $name) {
  48.             switch ($name) {
  49.                 case 'assetic':
  50.                     $asseticConfig = new AsseticConfiguration;
  51.                     $container->prependExtensionConfig(
  52.                         $name,
  53.                         array('assets' => $asseticConfig->build($config))
  54.                     );
  55.                     break;
  56.             }
  57.         }
  58.     }
  59. }