vendor/shopware/platform/src/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\Framework\Migration\MigrationSource;
  5. use Shopware\Core\Kernel;
  6. use Shopware\Storefront\DependencyInjection\DisableTemplateCachePass;
  7. use Shopware\Storefront\DependencyInjection\ReverseProxyCompilerPass;
  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.      * @var string
  24.      */
  25.     protected $name 'Storefront';
  26.     /**
  27.      * {@inheritdoc}
  28.      */
  29.     public function build(ContainerBuilder $container): void
  30.     {
  31.         parent::build($container);
  32.         $loader = new XmlFileLoader($container, new FileLocator(__DIR__ '/DependencyInjection'));
  33.         $loader->load('services.xml');
  34.         $loader->load('seo.xml');
  35.         $loader->load('controller.xml');
  36.         $loader->load('theme.xml');
  37.         $environment $container->getParameter('kernel.environment');
  38.         $this->buildConfig($container$environment);
  39.         $container->setParameter('storefrontRoot'$this->getPath());
  40.         $container->addCompilerPass(new DisableTemplateCachePass());
  41.         $container->addCompilerPass(new ReverseProxyCompilerPass());
  42.         // configure migration directories
  43.         $migrationSourceV3 $container->getDefinition(MigrationSource::class . '.core.V6_3');
  44.         $migrationSourceV3->addMethodCall('addDirectory', [$this->getMigrationPath() . '/V6_3'$this->getMigrationNamespace() . '\V6_3']);
  45.         // we've moved the migrations from Shopware\Core\Migration to Shopware\Core\Migration\v6_3
  46.         $migrationSourceV3->addMethodCall('addReplacementPattern', ['#^(Shopware\\\\Storefront\\\\Migration\\\\)V6_3\\\\([^\\\\]*)$#''$1$2']);
  47.         $migrationSourceV4 $container->getDefinition(MigrationSource::class . '.core.V6_4');
  48.         $migrationSourceV4->addMethodCall('addDirectory', [$this->getMigrationPath() . '/V6_4'$this->getMigrationNamespace() . '\V6_4']);
  49.         $migrationSourceV3->addMethodCall('addReplacementPattern', ['#^(Shopware\\\\Storefront\\\\Migration\\\\)V6_4\\\\([^\\\\]*)$#''$1$2']);
  50.         $migrationSourceV5 $container->getDefinition(MigrationSource::class . '.core.V6_5');
  51.         $migrationSourceV5->addMethodCall('addDirectory', [$this->getMigrationPath() . '/V6_5'$this->getMigrationNamespace() . '\V6_5']);
  52.     }
  53.     private function buildConfig(ContainerBuilder $container$environment): void
  54.     {
  55.         $locator = new FileLocator('Resources/config');
  56.         $resolver = new LoaderResolver([
  57.             new XmlFileLoader($container$locator),
  58.             new YamlFileLoader($container$locator),
  59.             new IniFileLoader($container$locator),
  60.             new PhpFileLoader($container$locator),
  61.             new GlobFileLoader($container$locator),
  62.             new DirectoryLoader($container$locator),
  63.             new ClosureLoader($container),
  64.         ]);
  65.         $configLoader = new DelegatingLoader($resolver);
  66.         $confDir $this->getPath() . '/Resources/config';
  67.         $configLoader->load($confDir '/{packages}/*' Kernel::CONFIG_EXTS'glob');
  68.         $configLoader->load($confDir '/{packages}/' $environment '/*' Kernel::CONFIG_EXTS'glob');
  69.     }
  70. }