<?php
declare(strict_types=1);
namespace App\Event;
use App\Event\ContactScoringEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use App\Services\Scoring\{
SaveContactScoreService,
DispatchAccountScoringService
};
class ContactScoringSubscriber implements EventSubscriberInterface
{
public function __construct(
private SaveContactScoreService $saveContactScoreService,
private DispatchAccountScoringService $dispatchAccountScoringService
) {
}
public static function getSubscribedEvents()
{
return [
ContactScoringEvent::NAME => 'onContactScoring',
];
}
public function onContactScoring(ContactScoringEvent $event): void
{
$this->saveContactScoreService->saveScore(
$event->getContact()
);
$this->dispatchAccountScoringService->scoring($event->getContact()->getAccount());
}
}