custom/plugins/NotFalseDistributors/src/NotFalseDistributors.php line 22

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace NotFalseDistributors\Shopware;
  3. use Shopware\Core\Framework\Plugin as SwagPlugin;
  4. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  5. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  6. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  7. use Shopware\Core\Kernel;
  8. use Symfony\Component\Config\Loader\DelegatingLoader;
  9. use Symfony\Component\Config\Loader\LoaderResolver;
  10. use Symfony\Component\DependencyInjection\ContainerBuilder;
  11. use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
  12. use Symfony\Component\DependencyInjection\Loader\DirectoryLoader;
  13. use Symfony\Component\DependencyInjection\Loader\GlobFileLoader;
  14. use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
  15. use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
  16. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  17. use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
  18. use Symfony\Component\Config\FileLocator;
  19. class NotFalseDistributors extends SwagPlugin
  20. {
  21.     public function build(ContainerBuilder $container): void
  22.     {
  23.         parent::build($container);
  24.         $this->buildConfig($container);
  25.     }
  26.     private function buildConfig(ContainerBuilder $container): void
  27.     {
  28.         $environment $container->getParameter('kernel.environment');
  29.         $locator  = new FileLocator('Resources/config');
  30.         $resolver = new LoaderResolver([
  31.             new XmlFileLoader($container$locator),
  32.             new YamlFileLoader($container$locator),
  33.             new IniFileLoader($container$locator),
  34.             new PhpFileLoader($container$locator),
  35.             new GlobFileLoader($container$locator),
  36.             new DirectoryLoader($container$locator),
  37.             new ClosureLoader($container),
  38.         ]);
  39.         $configLoader = new DelegatingLoader($resolver);
  40.         $confDir $this->getPath() . '/Resources/config';
  41.         $configLoader->load($confDir '/{packages}/*' Kernel::CONFIG_EXTS'glob');
  42.         $configLoader->load($confDir '/{packages}/' $environment '/*' Kernel::CONFIG_EXTS'glob');
  43.     }
  44.     public function install(InstallContext $installContext): void
  45.     {
  46.         parent::install($installContext);
  47.     }
  48.     public function uninstall(UninstallContext $context): void
  49.     {
  50.         parent::uninstall($context);
  51.         if ($context->keepUserData()) {
  52.             return;
  53.         }
  54.     }
  55.     public function update(UpdateContext $updateContext): void
  56.     {
  57.         parent::update($updateContext);
  58.     }
  59. }