vendor/ibexa/http-cache/src/lib/EventSubscriber/CachePurge/TrashEventsSubscriber.php line 24

Open in your IDE?
  1. <?php
  2. /**
  3. * @copyright Copyright (C) Ibexa AS. All rights reserved.
  4. * @license For full copyright and license information view LICENSE file distributed with this source code.
  5. */
  6. declare(strict_types=1);
  7. namespace Ibexa\HttpCache\EventSubscriber\CachePurge;
  8. use Ibexa\Contracts\Core\Repository\Events\Trash\RecoverEvent;
  9. use Ibexa\Contracts\Core\Repository\Events\Trash\TrashEvent;
  10. final class TrashEventsSubscriber extends AbstractSubscriber
  11. {
  12. public static function getSubscribedEvents(): array
  13. {
  14. return [
  15. TrashEvent::class => 'onTrash',
  16. RecoverEvent::class => 'onRecover',
  17. ];
  18. }
  19. public function onTrash(TrashEvent $event): void
  20. {
  21. $contentId = $event->getLocation()->contentId;
  22. $locationId = $event->getLocation()->id;
  23. $parentLocationId = $event->getLocation()->parentLocationId;
  24. $tags = array_merge(
  25. $this->getContentTags($contentId),
  26. $this->getLocationTags($locationId),
  27. $this->getParentLocationTags($parentLocationId)
  28. );
  29. $this->purgeClient->purge($tags);
  30. }
  31. public function onRecover(RecoverEvent $event): void
  32. {
  33. $contentId = $event->getLocation()->contentId;
  34. $parentLocationId = $event->getLocation()->parentLocationId;
  35. $tags = array_merge(
  36. $this->getContentTags($contentId),
  37. $this->getParentLocationTags($parentLocationId)
  38. );
  39. $this->purgeClient->purge($tags);
  40. }
  41. }
  42. class_alias(TrashEventsSubscriber::class, 'EzSystems\PlatformHttpCacheBundle\EventSubscriber\CachePurge\TrashEventsSubscriber');