vendor/ibexa/workflow/src/lib/Event/Subscriber/CleanupWorkflowMetadataSubscriber.php line 32

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\Workflow\Event\Subscriber;
  8. use Ibexa\Contracts\Core\Repository\Events\Content\PublishVersionEvent;
  9. use Ibexa\Contracts\Workflow\Persistence\Handler\HandlerInterface;
  10. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  11. class CleanupWorkflowMetadataSubscriber implements EventSubscriberInterface
  12. {
  13. /** @var \Ibexa\Contracts\Workflow\Persistence\Handler\HandlerInterface */
  14. private $handler;
  15. public function __construct(HandlerInterface $handler)
  16. {
  17. $this->handler = $handler;
  18. }
  19. public static function getSubscribedEvents(): array
  20. {
  21. return [
  22. PublishVersionEvent::class => ['onPublishVersion'],
  23. ];
  24. }
  25. public function onPublishVersion(PublishVersionEvent $event): void
  26. {
  27. $this->handler->cleanupWorkflowMetadataForContent($event->getVersionInfo()->contentInfo->id);
  28. }
  29. }