src/TeclaConnector/EventSubscriber/SynchronizeUpdatedRelationshipEmploymentSubscriber.php line 48
<?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\Relationship\Employment\UpdatedEvent;use App\TeclaConnector\Exception\Synchronizer\LegacySynchronizerFailedExceptionInterface;use App\TeclaConnector\Service\FailedLegacySynchronizerServiceInterface;use App\TeclaConnector\Synchronizer\EmploymentRelationship\LegacyUpdateSynchronizerInterface;use JetBrains\PhpStorm\ArrayShape;use Symfony\Component\EventDispatcher\EventSubscriberInterface;final class SynchronizeUpdatedRelationshipEmploymentSubscriber implements EventSubscriberInterface{private LegacyUpdateSynchronizerInterface $synchronizer;private FailedLegacySynchronizerServiceInterface $failedSynchronizerService;public function __construct(LegacyUpdateSynchronizerInterface $synchronizer, FailedLegacySynchronizerServiceInterface $failedSynchronizerService){$this->synchronizer = $synchronizer;$this->failedSynchronizerService = $failedSynchronizerService;}#[ArrayShape([UpdatedEvent::class => 'string'])]public static function getSubscribedEvents(): array{return [UpdatedEvent::class => 'onUpdated',];}public function onUpdated(UpdatedEvent $event): void{$relationship = $event->getRelationship();$originalData = $event->getOriginalData();if ($relationship->getStartDate() == ($originalData['startDate'] ?? null) && $relationship->getEndDate() == ($originalData['endDate'] ?? null)) {return;}try {$this->synchronizer->synchronize($relationship);} catch (LegacySynchronizerFailedExceptionInterface $e) {$this->failedSynchronizerService->create($e->getSynchronizerRequest());}}}