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

Open in your IDE?
  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.     /**
  17.      * @var ActivityRepositoryInterface
  18.      */
  19.     private $activityRepository;
  20.     public function __construct(
  21.         ActivityRepositoryInterface $activityRepository
  22.     ) {
  23.         $this->activityRepository $activityRepository;
  24.     }
  25.     public static function getSubscribedEvents()
  26.     {
  27.         return [
  28.             DomainEvent::class => ['storeActivity', -256],
  29.         ];
  30.     }
  31.     public function storeActivity(DomainEvent $event): void
  32.     {
  33.         $activity $this->activityRepository->createFromDomainEvent($event);
  34.         $this->activityRepository->addAndCommit($activity);
  35.     }
  36. }