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

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Swag\Markets;
  4. use Doctrine\DBAL\DBALException;
  5. use Exception;
  6. use Shopware\Core\Framework\DataAbstractionLayer\Exception\InconsistentCriteriaIdsException;
  7. use Shopware\Core\Framework\Plugin;
  8. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  9. use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  10. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  11. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  12. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  13. use Swag\Markets\Service\UninstallService;
  14. use Swag\Markets\Service\UpdateService;
  15. use Swag\Markets\Setup\ActivateDeactivate;
  16. use Symfony\Component\Config\FileLocator;
  17. use Symfony\Component\DependencyInjection\ContainerBuilder;
  18. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  19. class SwagMarkets extends Plugin
  20. {
  21.     /**
  22.      * @var ActivateDeactivate
  23.      */
  24.     private $activateDeactivate;
  25.     /**
  26.      * @Required
  27.      *
  28.      * @param ActivateDeactivate $activateDeactivate
  29.      */
  30.     public function setActivate(ActivateDeactivate $activateDeactivate): void
  31.     {
  32.         $this->activateDeactivate $activateDeactivate;
  33.     }
  34.     /**
  35.      * @param ContainerBuilder $container
  36.      * @throws Exception
  37.      */
  38.     public function build(ContainerBuilder $container): void
  39.     {
  40.         parent::build($container);
  41.         $loader = new XmlFileLoader($container, new FileLocator(__DIR__ '/DependencyInjection'));
  42.         $loader->load('installment.xml');
  43.     }
  44.     /**
  45.      * @return string
  46.      */
  47.     public function getServicesFilePath(): string
  48.     {
  49.         return 'DependencyInjection/subscribers.xml';
  50.     }
  51.     /**
  52.      * @param InstallContext $installContext
  53.      */
  54.     public function install(InstallContext $installContext): void
  55.     {
  56.         parent::install($installContext);
  57.     }
  58.     /**
  59.      * @param  UninstallContext  $uninstallContext
  60.      * @throws DBALException
  61.      * @throws \ErrorException
  62.      */
  63.     public function uninstall(UninstallContext $uninstallContext): void
  64.     {
  65.         (new UninstallService($uninstallContext$this->container))->uninstall();
  66.         parent::uninstall($uninstallContext);
  67.     }
  68.     /**
  69.      * @param ActivateContext $activateContext
  70.      */
  71.     public function activate(ActivateContext $activateContext): void
  72.     {
  73.         $this->activateDeactivate->activate($activateContext);
  74.         parent::activate($activateContext);
  75.     }
  76.     /**
  77.      * @param DeactivateContext $deactivateContext
  78.      * @throws InconsistentCriteriaIdsException
  79.      */
  80.     public function deactivate(DeactivateContext $deactivateContext): void
  81.     {
  82.         parent::deactivate($deactivateContext);
  83.     }
  84.     /**
  85.      * @param UpdateContext $updateContext
  86.      */
  87.     public function update(UpdateContext $updateContext): void
  88.     {
  89.         (new UpdateService())->update($updateContext$this->container);
  90.     }
  91. }