<?php declare(strict_types=1);namespace Shopware\Core\Framework\MessageQueue\ScheduledTask\Subscriber;use Psr\Cache\CacheItemPoolInterface;use Shopware\Core\Framework\Log\Package;use Shopware\Core\Framework\MessageQueue\ScheduledTask\Registry\TaskRegistry;use Shopware\Core\Framework\Plugin\Event\PluginPostActivateEvent;use Shopware\Core\Framework\Plugin\Event\PluginPostDeactivateEvent;use Shopware\Core\Framework\Plugin\Event\PluginPostUpdateEvent;use Symfony\Component\EventDispatcher\EventSubscriberInterface;use Symfony\Component\Messenger\EventListener\StopWorkerOnRestartSignalListener;/** * @deprecated tag:v6.5.0 - reason:becomes-internal - EventSubscribers will become internal in v6.5.0 */#[Package('system-settings')]class PluginLifecycleSubscriber implements EventSubscriberInterface{ private TaskRegistry $registry; private CacheItemPoolInterface $restartSignalCachePool; /** * @internal */ public function __construct(TaskRegistry $registry, CacheItemPoolInterface $restartSignalCachePool) { $this->registry = $registry; $this->restartSignalCachePool = $restartSignalCachePool; } public static function getSubscribedEvents(): array { return [ PluginPostActivateEvent::class => 'afterPluginStateChange', PluginPostDeactivateEvent::class => 'afterPluginStateChange', PluginPostUpdateEvent::class => 'afterPluginStateChange', ]; } public function afterPluginStateChange(): void { $this->registry->registerTasks(); // signal worker restart $cacheItem = $this->restartSignalCachePool->getItem(StopWorkerOnRestartSignalListener::RESTART_REQUESTED_TIMESTAMP_KEY); $cacheItem->set(microtime(true)); $this->restartSignalCachePool->save($cacheItem); }}