vendor/store.shopware.com/laenengrid/src/LaenenGrid.php line 11

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Laenen\Grid;
  3. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
  4. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
  6. use Shopware\Core\Framework\Plugin;
  7. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  8. class LaenenGrid extends Plugin
  9. {
  10.     public function uninstall(UninstallContext $uninstallContext): void
  11.     {
  12.         if ($uninstallContext->keepUserData()) {
  13.             return;
  14.         }
  15.         /** @var EntityRepositoryInterface $sectionRepository */
  16.         $sectionRepository $this->container->get('cms_section.repository');
  17.         // Remove all grid sections and their data
  18.         $criteria = new Criteria();
  19.         $criteria->addFilter(new EqualsFilter('type''lae-grid'));
  20.         $ids $sectionRepository->searchIds($criteria$uninstallContext->getContext());
  21.         $sectionRepository->delete(
  22.             array_map(function ($id) {
  23.                 return ['id' => $id];
  24.             }, $ids->getIds()),
  25.             $uninstallContext->getContext()
  26.         );
  27.     }
  28. }