custom/plugins/WynCustomerTheme/src/WynCustomerTheme.php line 12

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