vendor/shopware/storefront/Storefront.php line 28

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