src/Subscriber/UserGroups/UserGroupThreadSubscriber.php line 38

Open in your IDE?
  1. <?php
  2. namespace App\Subscriber\UserGroups;
  3. use App\Event\UserGroups\ThreadDeletedEvent;
  4. use App\Service\UserGroups\GroupService;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class UserGroupThreadSubscriber implements EventSubscriberInterface
  7. {
  8.     /**
  9.      * @var GroupService
  10.      */
  11.     protected $service;
  12.     /**
  13.      * UserGroupThreadSubscriber constructor.
  14.      */
  15.     public function __construct(GroupService $service)
  16.     {
  17.         $this->service $service;
  18.     }
  19.     public static function getSubscribedEvents(): array
  20.     {
  21.         return [
  22.             ThreadDeletedEvent::class => [
  23.                 ['onThreadDeletedCalculateGroupStatPostCount'0],
  24.             ],
  25.         ];
  26.     }
  27.     /**
  28.      * @throws \Doctrine\DBAL\Exception
  29.      * @throws \Doctrine\ORM\ORMException
  30.      * @throws \Doctrine\ORM\OptimisticLockException
  31.      */
  32.     public function onThreadDeletedCalculateGroupStatPostCount(ThreadDeletedEvent $event)
  33.     {
  34.         $thread $event->getEntity();
  35.         $group $thread->getUserGroup();
  36.         $this->service->calculateUserGroupStatPostCount($group);
  37.     }
  38. }