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.      * {@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.         // configure migration directories
  39.         $migrationSourceV3 $container->getDefinition(MigrationSource::class . '.core.V6_3');
  40.         $migrationSourceV3->addMethodCall('addDirectory', [$this->getMigrationPath() . '/V6_3'$this->getMigrationNamespace() . '\V6_3']);
  41.         // we've moved the migrations from Shopware\Core\Migration to Shopware\Core\Migration\v6_3
  42.         $migrationSourceV3->addMethodCall('addReplacementPattern', ['#^(Shopware\\\\Storefront\\\\Migration\\\\)V6_3\\\\([^\\\\]*)$#''$1$2']);
  43.         $migrationSourceV4 $container->getDefinition(MigrationSource::class . '.core.V6_4');
  44.         $migrationSourceV4->addMethodCall('addDirectory', [$this->getMigrationPath() . '/V6_4'$this->getMigrationNamespace() . '\V6_4']);
  45.         $migrationSourceV3->addMethodCall('addReplacementPattern', ['#^(Shopware\\\\Storefront\\\\Migration\\\\)V6_4\\\\([^\\\\]*)$#''$1$2']);
  46.         $migrationSourceV5 $container->getDefinition(MigrationSource::class . '.core.V6_5');
  47.         $migrationSourceV5->addMethodCall('addDirectory', [$this->getMigrationPath() . '/V6_5'$this->getMigrationNamespace() . '\V6_5']);
  48.     }
  49.     private function buildConfig(ContainerBuilder $container$environment): void
  50.     {
  51.         $locator = new FileLocator('Resources/config');
  52.         $resolver = new LoaderResolver([
  53.             new XmlFileLoader($container$locator),
  54.             new YamlFileLoader($container$locator),
  55.             new IniFileLoader($container$locator),
  56.             new PhpFileLoader($container$locator),
  57.             new GlobFileLoader($container$locator),
  58.             new DirectoryLoader($container$locator),
  59.             new ClosureLoader($container),
  60.         ]);
  61.         $configLoader = new DelegatingLoader($resolver);
  62.         $confDir $this->getPath() . '/Resources/config';
  63.         $configLoader->load($confDir '/{packages}/*' Kernel::CONFIG_EXTS'glob');
  64.         $configLoader->load($confDir '/{packages}/' $environment '/*' Kernel::CONFIG_EXTS'glob');
  65.     }
  66. }