vendor/shopware/storefront/Storefront.php line 23

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Storefront;
  3. use Shopware\Core\Framework\Bundle;
  4. use Shopware\Core\Kernel;
  5. use Shopware\Storefront\DependencyInjection\DisableTemplateCachePass;
  6. use Shopware\Storefront\DependencyInjection\ReverseProxyCompilerPass;
  7. use Shopware\Storefront\DependencyInjection\StorefrontMigrationReplacementCompilerPass;
  8. use Shopware\Storefront\Framework\ThemeInterface;
  9. use Symfony\Component\Config\FileLocator;
  10. use Symfony\Component\Config\Loader\DelegatingLoader;
  11. use Symfony\Component\Config\Loader\LoaderResolver;
  12. use Symfony\Component\DependencyInjection\ContainerBuilder;
  13. use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
  14. use Symfony\Component\DependencyInjection\Loader\DirectoryLoader;
  15. use Symfony\Component\DependencyInjection\Loader\GlobFileLoader;
  16. use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
  17. use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
  18. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  19. use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
  20. class Storefront extends Bundle implements ThemeInterface
  21. {
  22.     /**
  23.      * {@inheritdoc}
  24.      */
  25.     public function build(ContainerBuilder $container): void
  26.     {
  27.         parent::build($container);
  28.         $loader = new XmlFileLoader($container, new FileLocator(__DIR__ '/DependencyInjection'));
  29.         $loader->load('services.xml');
  30.         $loader->load('seo.xml');
  31.         $loader->load('controller.xml');
  32.         $loader->load('theme.xml');
  33.         $environment $container->getParameter('kernel.environment');
  34.         $this->buildConfig($container$environment);
  35.         $container->setParameter('storefrontRoot'$this->getPath());
  36.         $container->addCompilerPass(new DisableTemplateCachePass());
  37.         $container->addCompilerPass(new ReverseProxyCompilerPass());
  38.         $container->addCompilerPass(new StorefrontMigrationReplacementCompilerPass());
  39.     }
  40.     private function buildConfig(ContainerBuilder $container$environment): void
  41.     {
  42.         $locator = new FileLocator('Resources/config');
  43.         $resolver = new LoaderResolver([
  44.             new XmlFileLoader($container$locator),
  45.             new YamlFileLoader($container$locator),
  46.             new IniFileLoader($container$locator),
  47.             new PhpFileLoader($container$locator),
  48.             new GlobFileLoader($container$locator),
  49.             new DirectoryLoader($container$locator),
  50.             new ClosureLoader($container),
  51.         ]);
  52.         $configLoader = new DelegatingLoader($resolver);
  53.         $confDir $this->getPath() . '/Resources/config';
  54.         $configLoader->load($confDir '/{packages}/*' Kernel::CONFIG_EXTS'glob');
  55.         $configLoader->load($confDir '/{packages}/' $environment '/*' Kernel::CONFIG_EXTS'glob');
  56.     }
  57. }