src/TeclaConnector/EventSubscriber/SynchronizeCreatedUserSubscriber.php line 59
<?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\Core\Event\UserRegistrationConfirmedEvent;use App\Core\Event\UserRegistrationSuccessEvent;use App\Core\Model\UserInterface;use App\TeclaConnector\Exception\Synchronizer\LegacySynchronizerFailedExceptionInterface;use App\TeclaConnector\Service\FailedLegacySynchronizerServiceInterface;use App\TeclaConnector\Synchronizer\User\LegacyCreateSynchronizerInterface;use JetBrains\PhpStorm\ArrayShape;use Symfony\Component\EventDispatcher\EventSubscriberInterface;final class SynchronizeCreatedUserSubscriber implements EventSubscriberInterface{private LegacyCreateSynchronizerInterface $synchronizer;private FailedLegacySynchronizerServiceInterface $failedSynchronizerService;public function __construct(LegacyCreateSynchronizerInterface $synchronizer, FailedLegacySynchronizerServiceInterface $failedSynchronizerService){$this->synchronizer = $synchronizer;$this->failedSynchronizerService = $failedSynchronizerService;}#[ArrayShape([UserRegistrationSuccessEvent::class => 'string',UserRegistrationConfirmedEvent::class => 'string',])]public static function getSubscribedEvents(): array{return [UserRegistrationSuccessEvent::class => 'onUserRegistrationSuccess',UserRegistrationConfirmedEvent::class => 'onUserRegistrationConfirmedEvent',];}public function onUserRegistrationSuccess(UserRegistrationSuccessEvent $event): void{$this->synchronizeCreatedUser($event->getUser());}public function onUserRegistrationConfirmedEvent(UserRegistrationConfirmedEvent $event): void{$this->synchronizeCreatedUser($event->getUser());}private function synchronizeCreatedUser(UserInterface $user): void{try {$this->synchronizer->synchronize($user);} catch (LegacySynchronizerFailedExceptionInterface $e) {$this->failedSynchronizerService->create($e->getSynchronizerRequest());}}}