src/Event/ContactScoringSubscriber.php line 29

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Event;
  4. use App\Event\ContactScoringEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use App\Services\Scoring\{
  7.     SaveContactScoreService,
  8.     DispatchAccountScoringService
  9. };
  10. class ContactScoringSubscriber implements EventSubscriberInterface
  11. {
  12.     public function __construct(
  13.         private SaveContactScoreService $saveContactScoreService,
  14.         private DispatchAccountScoringService $dispatchAccountScoringService
  15.     ) {
  16.     }
  17.     public static function getSubscribedEvents()
  18.     {
  19.         return [
  20.             ContactScoringEvent::NAME => 'onContactScoring',
  21.         ];
  22.     }
  23.     public function onContactScoring(ContactScoringEvent $event): void
  24.     {
  25.         $this->saveContactScoreService->saveScore(
  26.             $event->getContact()
  27.         );
  28.         $this->dispatchAccountScoringService->scoring($event->getContact()->getAccount());
  29.     }
  30. }