vendor/shopware/core/Framework/Webhook/WebhookCacheClearer.php line 45

  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\Webhook;
  3. use Shopware\Core\Framework\Log\Package;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use Symfony\Contracts\Service\ResetInterface;
  6. /**
  7.  * @internal
  8.  */
  9. #[Package('core')]
  10. class WebhookCacheClearer implements EventSubscriberInterfaceResetInterface
  11. {
  12.     /**
  13.      * @internal
  14.      */
  15.     public function __construct(private readonly WebhookDispatcher $dispatcher)
  16.     {
  17.     }
  18.     public static function getSubscribedEvents(): array
  19.     {
  20.         return [
  21.             'webhook.written' => 'clearWebhookCache',
  22.             'acl_role.written' => 'clearPrivilegesCache',
  23.         ];
  24.     }
  25.     /**
  26.      * Reset can not be handled by the Dispatcher itself, as it may be in the middle of a decoration chain
  27.      * Therefore tagging that service directly won't work
  28.      */
  29.     public function reset(): void
  30.     {
  31.         $this->clearWebhookCache();
  32.         $this->clearPrivilegesCache();
  33.     }
  34.     public function clearWebhookCache(): void
  35.     {
  36.         $this->dispatcher->clearInternalWebhookCache();
  37.     }
  38.     public function clearPrivilegesCache(): void
  39.     {
  40.         $this->dispatcher->clearInternalPrivilegesCache();
  41.     }
  42. }