src/Contact/EventSubscriber/SetInitialAccessTrackingSubscriber.php line 43

  1. <?php
  2. declare(strict_types=1);
  3. /**
  4.  * Copyright (c) 2022 TECLA Consulting Group oü.
  5.  * All rights reserved.
  6.  *
  7.  * This unpublished material is proprietary to TECLA Consulting Group oü.
  8.  * All rights reserved. The methods and
  9.  * techniques described herein are considered trade secrets
  10.  * and/or confidential. Reproduction or distribution, in whole
  11.  * or in part, is forbidden except by express written permission
  12.  * of TECLA Consulting Group oü.
  13.  *
  14.  * @author    Matúš Sýkorjak <matus@tecla.no>
  15.  * @copyright 2022 TECLA Consulting Group oü
  16.  */
  17. namespace App\Contact\EventSubscriber;
  18. use App\Contact\Event\ContactAccess\CreatedEvent;
  19. use App\Contact\Service\ContactAccessTrackingServiceInterface;
  20. use JetBrains\PhpStorm\ArrayShape;
  21. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  22. final class SetInitialAccessTrackingSubscriber implements EventSubscriberInterface
  23. {
  24.     private ContactAccessTrackingServiceInterface $accessTrackingService;
  25.     public function __construct(ContactAccessTrackingServiceInterface $accessTrackingService)
  26.     {
  27.         $this->accessTrackingService $accessTrackingService;
  28.     }
  29.     #[ArrayShape([CreatedEvent::class => 'string'])]
  30.     public static function getSubscribedEvents(): array
  31.     {
  32.         return [
  33.             CreatedEvent::class => 'onContactAccessCreated',
  34.         ];
  35.     }
  36.     public function onContactAccessCreated(CreatedEvent $event): void
  37.     {
  38.         $access $event->getContactAccess();
  39.         $this->accessTrackingService->track($access->getContact(), $access->getAccessor());
  40.     }
  41. }