vendor/store.shopware.com/swpasort/src/SwpaSort.php line 26

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Swpa\SwpaSort;
  3. use Doctrine\DBAL\Connection;
  4. use Exception;
  5. use Shopware\Core\Framework\Plugin;
  6. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  7. use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  8. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  9. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  10. use Shopware\Core\System\SystemConfig\SystemConfigService;
  11. use Swpa\SwpaSort\DependencyInjection\Compiler\SortingServicePass;
  12. use Swpa\SwpaSort\Setup;
  13. use Symfony\Component\Config\FileLocator;
  14. use Symfony\Component\DependencyInjection\ContainerBuilder;
  15. use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
  16. /**
  17.  * Main class of the plugin SwpaSort:
  18.  *
  19.  * @package Swpa\SwpaSort
  20.  * @license See COPYING.txt for license details
  21.  * @author  swpa <info@swpa.dev>
  22.  */
  23. class SwpaSort extends Plugin
  24. {
  25.     /**
  26.      * @param ContainerBuilder $container
  27.      *
  28.      * @throws Exception
  29.      */
  30.     public function build(ContainerBuilder $container): void
  31.     {
  32.         $yamlLoader = new YamlFileLoader($container, new FileLocator(__DIR__ '/Resources/config'));
  33.         $yamlLoader->load('services.yml');
  34.         $container->addCompilerPass(new SortingServicePass());
  35.         parent::build($container);
  36.     }
  37.     /**
  38.      * @return string
  39.      */
  40.     public function getStorefrontScriptPath(): string
  41.     {
  42.         return 'Resources/dist/storefront/js';
  43.     }
  44.     /**
  45.      * @param InstallContext $context
  46.      */
  47.     public function install(InstallContext $context): void
  48.     {
  49.         $install = new Setup\Install($this->container->get(Connection::class));
  50.         $install->install($context);
  51.         parent::install($context);
  52.     }
  53.     /**
  54.      * @param UninstallContext $context
  55.      */
  56.     public function uninstall(UninstallContext $context): void
  57.     {
  58.         $install = new Setup\Uninstall($this->container->get(Connection::class));
  59.         $install->uninstall($context);
  60.         parent::uninstall($context);
  61.     }
  62.     /**
  63.      * @param ActivateContext $context
  64.      */
  65.     public function activate(ActivateContext $context): void
  66.     {
  67.         $install = new Setup\Activate(
  68.             $this->container->get(Connection::class),
  69.             $this->container->get(SystemConfigService::class)
  70.         );
  71.         $install->activate($context);
  72.         parent::activate($context);
  73.     }
  74.     /**
  75.      * @param DeactivateContext $context
  76.      */
  77.     public function deactivate(DeactivateContext $context): void
  78.     {
  79.         $install = new Setup\Deactivate($this->container->get(Connection::class));
  80.         $install->deactivate($context);
  81.         parent::deactivate($context);
  82.     }
  83. }