vendor/store.shopware.com/froshtools/src/FroshTools.php line 21

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Frosh\Tools;
  3. use Composer\Autoload\ClassLoader;
  4. use Frosh\Tools\Components\Lightningcss\Compiler;
  5. use Frosh\Tools\Components\Messenger\TaskLoggingMiddlewareCompilerPass;
  6. use Frosh\Tools\DependencyInjection\CacheCompilerPass;
  7. use Frosh\Tools\DependencyInjection\DisableElasticsearchCompilerPass;
  8. use Frosh\Tools\DependencyInjection\FroshToolsExtension;
  9. use Frosh\Tools\DependencyInjection\SymfonyConfigCompilerPass;
  10. use Shopware\Core\Framework\Plugin;
  11. use Shopware\Core\Kernel;
  12. use Symfony\Component\Config\FileLocator;
  13. use Symfony\Component\Config\Loader\DelegatingLoader;
  14. use Symfony\Component\Config\Loader\LoaderResolver;
  15. use Symfony\Component\DependencyInjection\ContainerBuilder;
  16. use Symfony\Component\DependencyInjection\Loader\GlobFileLoader;
  17. use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
  18. class FroshTools extends Plugin
  19. {
  20.     public function build(ContainerBuilder $container): void
  21.     {
  22.         parent::build($container);
  23.         $container->addCompilerPass(new CacheCompilerPass());
  24.         $container->addCompilerPass(new TaskLoggingMiddlewareCompilerPass());
  25.         $container->addCompilerPass(new SymfonyConfigCompilerPass());
  26.         $container->addCompilerPass(new DisableElasticsearchCompilerPass());
  27.         $this->buildConfig($container);
  28.     }
  29.     public function createContainerExtension(): FroshToolsExtension
  30.     {
  31.         return new FroshToolsExtension();
  32.     }
  33.     private function buildConfig(ContainerBuilder $container): void
  34.     {
  35.         $locator = new FileLocator('Resources/config');
  36.         $resolver = new LoaderResolver([
  37.             new YamlFileLoader($container$locator),
  38.             new GlobFileLoader($container$locator),
  39.         ]);
  40.         $configLoader = new DelegatingLoader($resolver);
  41.         $confDir $this->getPath() . '/Resources/config';
  42.         $configLoader->load($confDir '/{packages}/*' Kernel::CONFIG_EXTS'glob');
  43.     }
  44.     public function boot(): void
  45.     {
  46.         parent::boot();
  47.         if ($this->container->hasParameter('frosh_tools.storefront.lightningcss.enabled') && $this->container->getParameter('frosh_tools.storefront.lightningcss.enabled')) {
  48.             Compiler::setApiURL($this->container->getParameter('frosh_tools.storefront.lightningcss.api_url'));
  49.             Compiler::setBrowserList($this->container->getParameter('frosh_tools.storefront.lightningcss.browserlist'));
  50.             Compiler::setLogger($this->container->get('logger'));
  51.             if (!class_exists('\Padaliyajay\PHPAutoprefixer\Autoprefixer'false)) {
  52.                 class_alias(Compiler::class, '\Padaliyajay\PHPAutoprefixer\Autoprefixer');
  53.             }
  54.         }
  55.     }
  56. }