vendor/shopware/storefront/Theme/Subscriber/AppLifecycleSubscriber.php line 33

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Storefront\Theme\Subscriber;
  3. use Shopware\Core\Framework\App\Event\AppDeletedEvent;
  4. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  6. use Shopware\Storefront\Theme\ThemeLifecycleService;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. class AppLifecycleSubscriber implements EventSubscriberInterface
  9. {
  10.     private ThemeLifecycleService $themeLifecycleService;
  11.     private EntityRepositoryInterface $appRepository;
  12.     public function __construct(ThemeLifecycleService $themeLifecycleServiceEntityRepositoryInterface $appRepository)
  13.     {
  14.         $this->themeLifecycleService $themeLifecycleService;
  15.         $this->appRepository $appRepository;
  16.     }
  17.     /**
  18.      * @return array<string, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
  19.      */
  20.     public static function getSubscribedEvents()
  21.     {
  22.         return [
  23.             AppDeletedEvent::class => 'onAppDeleted',
  24.         ];
  25.     }
  26.     public function onAppDeleted(AppDeletedEvent $event): void
  27.     {
  28.         if ($event->keepUserData()) {
  29.             return;
  30.         }
  31.         $app $this->appRepository->search((new Criteria([$event->getAppId()])), $event->getContext())->first();
  32.         if ($app === null) {
  33.             return;
  34.         }
  35.         $this->themeLifecycleService->removeTheme($app->getName(), $event->getContext());
  36.     }
  37. }