src/TeclaConnector/EventSubscriber/SynchronizeCreatedContactSubscriber.php line 50
<?phpdeclare(strict_types=1);/*** Copyright (c) 2020 TECLA Consulting Group oü.* All rights reserved.** This unpublished material is proprietary to TECLA Consulting Group oü.* All rights reserved. The methods and* techniques described herein are considered trade secrets* and/or confidential. Reproduction or distribution, in whole* or in part, is forbidden except by express written permission* of TECLA Consulting Group oü.** @author Matúš Sýkorjak <matus@tecla.no>* @copyright 2020 TECLA Consulting Group oü*/namespace App\TeclaConnector\EventSubscriber;use App\Contact\Event\ContactCreatedEvent;use App\TeclaConnector\Exception\Synchronizer\LegacySynchronizerFailedExceptionInterface;use App\TeclaConnector\Service\FailedLegacySynchronizerServiceInterface;use App\TeclaConnector\Synchronizer\Contact\LegacyCreateSynchronizerInterface;use JetBrains\PhpStorm\ArrayShape;use Symfony\Component\EventDispatcher\EventSubscriberInterface;final class SynchronizeCreatedContactSubscriber implements EventSubscriberInterface{private LegacyCreateSynchronizerInterface $createdContactSynchronizer;private FailedLegacySynchronizerServiceInterface $failedSynchronizerService;public function __construct(LegacyCreateSynchronizerInterface $createdContactSynchronizer,FailedLegacySynchronizerServiceInterface $failedSynchronizerService) {$this->createdContactSynchronizer = $createdContactSynchronizer;$this->failedSynchronizerService = $failedSynchronizerService;}#[ArrayShape([ContactCreatedEvent::class => 'array'])]public static function getSubscribedEvents(): array{return [ContactCreatedEvent::class => ['onContactCreated', 10],];}public function onContactCreated(ContactCreatedEvent $event): void{if (false === $event->getSynchronize()) {return;}$contact = $event->getContact();try {$this->createdContactSynchronizer->synchronize($contact);} catch (LegacySynchronizerFailedExceptionInterface $e) {$this->failedSynchronizerService->create($e->getSynchronizerRequest());}}}