custom/plugins/EightworksCookieConsentPlus6/src/EightworksCookieConsentPlus6.php line 31

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Eightworks\EightworksCookieConsentPlus6;
  3. /**
  4.  * \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  5.  *  ______ ________ _______ ______ __  __ _______
  6.  * |  __  |  |  |  |       |   __ \  |/  |     __|
  7.  * |  __  |  |  |  |   -   |      <     <|__     |
  8.  * |______|________|_______|___|__|__|\__|_______|
  9.  *
  10.  *  ####+++---   C  O  N  T  A  C  T   –--++++####
  11.  *
  12.  *  Internetagentur 8works
  13.  *  WEB: 8works.de
  14.  *  MAIL: info@8works.de
  15.  *
  16.  * \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  17.  **/
  18. use Shopware\Core\Framework\Plugin;
  19. use Shopware\Core\Framework\Context;
  20. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
  21. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  22. use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\ContainsFilter;
  23. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  24. use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  25. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  26. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  27. class EightworksCookieConsentPlus6 extends Plugin
  28. {
  29.     public function boot(): void
  30.     {
  31.         parent::boot();
  32.     }
  33.     /**
  34.      * Install plugin
  35.      *
  36.      * @param InstallContext $context
  37.      * @return void
  38.      */
  39.     public function install(InstallContext $context) : void
  40.     {
  41.         parent::install($context);
  42.     }
  43.     /**
  44.      * Uninstall plugin
  45.      *
  46.      * @param UninstallContext $context
  47.      * @return void
  48.      */
  49.     public function uninstall(UninstallContext $context): void
  50.     {
  51.         parent::uninstall($context);
  52.         if ($context->keepUserData()) {
  53.             return;
  54.         }
  55.         $this->removeConfiguration($context->getContext());
  56.     }
  57.     /**
  58.      * Remove configuration
  59.      *
  60.      * @param Context $context
  61.      * @return void
  62.      */
  63.     private function removeConfiguration(Context $context): void
  64.     {
  65.         /** @var EntityRepositoryInterface $systemConfigRepository */
  66.         $systemConfigRepository $this->container->get('system_config.repository');
  67.         $criteria = (new Criteria())->addFilter(new ContainsFilter('configurationKey'$this->getName() . '.config.'));
  68.         $idSearchResult $systemConfigRepository->searchIds($criteria$context);
  69.         $ids array_map(static function ($id) {
  70.             return ['id' => $id];
  71.         }, $idSearchResult->getIds());
  72.         if ($ids === []) {
  73.             return;
  74.         }
  75.         $systemConfigRepository->delete($ids$context);
  76.     }
  77.     /**
  78.      * Activate plugin
  79.      *
  80.      * @param ActivateContext $context
  81.      * @return void
  82.      */
  83.     public function activate(ActivateContext $context) : void
  84.     {
  85.         parent::activate($context);
  86.     }
  87.     /**
  88.      * Deactivate plugin
  89.      *
  90.      * @param DeactivateContext $context
  91.      * @return void
  92.      */
  93.     public function deactivate(DeactivateContext $context) : void
  94.     {
  95.         parent::deactivate($context);
  96.     }
  97. }