custom/plugins/MSTManufacturerSlider6/src/MSTManufacturerSlider6.php line 13

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace MST\MSTManufacturerSlider6;
  4. use Shopware\Core\Framework\Context;
  5. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
  6. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  7. use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\ContainsFilter;
  8. use Shopware\Core\Framework\Plugin;
  9. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  10. class MSTManufacturerSlider6 extends Plugin
  11. {
  12.     public function uninstall(UninstallContext $uninstallContext): void
  13.     {
  14.         parent::uninstall($uninstallContext);
  15.         if ($uninstallContext->keepUserData()) {
  16.             return;
  17.         }
  18.         $this->removeConfiguration($uninstallContext->getContext());
  19.     }
  20.     private function removeConfiguration(Context $context): void
  21.     {
  22.         /** @var EntityRepository $systemConfigRepository */
  23.         $systemConfigRepository $this->container->get('system_config.repository');
  24.         $criteria = (new Criteria())->addFilter(new ContainsFilter('configurationKey'$this->getName() . '.config.'));
  25.         $idSearchResult $systemConfigRepository->searchIds($criteria$context);
  26.         $ids array_map(static function ($id) {
  27.             return ['id' => $id];
  28.         }, $idSearchResult->getIds());
  29.         if ($ids === []) {
  30.             return;
  31.         }
  32.         $systemConfigRepository->delete($ids$context);
  33.     }
  34. }