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

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. /**
  9.  * @deprecated tag:v6.5.0 - reason:becomes-internal - EventSubscribers will become internal in v6.5.0
  10.  */
  11. class AppLifecycleSubscriber implements EventSubscriberInterface
  12. {
  13.     private ThemeLifecycleService $themeLifecycleService;
  14.     private EntityRepositoryInterface $appRepository;
  15.     /**
  16.      * @internal
  17.      */
  18.     public function __construct(ThemeLifecycleService $themeLifecycleServiceEntityRepositoryInterface $appRepository)
  19.     {
  20.         $this->themeLifecycleService $themeLifecycleService;
  21.         $this->appRepository $appRepository;
  22.     }
  23.     /**
  24.      * @return array<string, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
  25.      */
  26.     public static function getSubscribedEvents()
  27.     {
  28.         return [
  29.             AppDeletedEvent::class => 'onAppDeleted',
  30.         ];
  31.     }
  32.     public function onAppDeleted(AppDeletedEvent $event): void
  33.     {
  34.         if ($event->keepUserData()) {
  35.             return;
  36.         }
  37.         $app $this->appRepository->search((new Criteria([$event->getAppId()])), $event->getContext())->first();
  38.         if ($app === null) {
  39.             return;
  40.         }
  41.         $this->themeLifecycleService->removeTheme($app->getName(), $event->getContext());
  42.     }
  43. }