vendor/sulu/sulu/src/Sulu/Bundle/ActivityBundle/Application/Subscriber/StoreActivitySubscriber.php line 38

  1. <?php
  2. /*
  3.  * This file is part of Sulu.
  4.  *
  5.  * (c) Sulu GmbH
  6.  *
  7.  * This source file is subject to the MIT license that is bundled
  8.  * with this source code in the file LICENSE.
  9.  */
  10. namespace Sulu\Bundle\ActivityBundle\Application\Subscriber;
  11. use Sulu\Bundle\ActivityBundle\Domain\Event\DomainEvent;
  12. use Sulu\Bundle\ActivityBundle\Domain\Repository\ActivityRepositoryInterface;
  13. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  14. class StoreActivitySubscriber implements EventSubscriberInterface
  15. {
  16.     public function __construct(
  17.         private ActivityRepositoryInterface $activityRepository
  18.     ) {
  19.     }
  20.     public static function getSubscribedEvents()
  21.     {
  22.         return [
  23.             DomainEvent::class => ['storeActivity', -256],
  24.         ];
  25.     }
  26.     public function storeActivity(DomainEvent $event): void
  27.     {
  28.         $activity $this->activityRepository->createFromDomainEvent($event);
  29.         $this->activityRepository->addAndCommit($activity);
  30.     }
  31. }