@@ -31,49 +31,39 @@ public function __construct(
3131 private readonly RepositoryInterface $ customerRepository ,
3232 private readonly UserComApiAwareResourceProviderInterface $ userComApiAwareResourceProvider ,
3333 private readonly CustomerUpdateManagerInterface $ updateManager ,
34- private readonly LoggerInterface $ logger ,
3534 ) {
3635 }
3736
3837 public function __invoke (UserSynchronization $ userSynchronization ): void
3938 {
40- try {
41- Assert::isInstanceOf ($ this ->customerRepository , CustomerRepositoryInterface::class);
42- Assert::isInstanceOf ($ this ->addressRepository , AddressRepositoryInterface::class);
43-
44- $ customer = $ this ->customerRepository ->find ($ userSynchronization ->getCustomerId ());
45- Assert::isInstanceOf ($ customer , CustomerInterface::class);
46-
47- $ email = $ userSynchronization ->getEmail ();
48-
49- $ addressId = $ userSynchronization ->getAddressId ();
50- $ address = $ this ->getAddress ($ addressId );
51-
52- $ resourceId = $ userSynchronization ->getUserComApiAwareResourceId ();
53-
54- $ userComApiAwareResource = $ this ->userComApiAwareResourceProvider ->getApiAwareResourceById ($ resourceId );
55- if (null === $ userComApiAwareResource ) {
56- throw new UnrecoverableMessageHandlingException ('User.com API-aware resource not found ' );
57- }
58-
59- $ eventName = $ userSynchronization ->getEventName ();
60-
61- $ this ->updateManager ->manageChange (
62- $ eventName ,
63- $ userComApiAwareResource ,
64- $ customer ,
65- $ address ,
66- $ email ,
67- $ userSynchronization ->getUserComCookie (),
68- );
69- } catch (\Exception $ exception ) {
70- $ this ->logger ->critical (sprintf ('User.com synchronization failed - %s ' , $ exception ->getMessage ()));
71- if ($ exception instanceof RecoverableMessageHandlingException) {
72- throw $ exception ;
73- }
74-
75- throw new UnrecoverableMessageHandlingException ($ exception ->getMessage ());
39+ Assert::isInstanceOf ($ this ->customerRepository , CustomerRepositoryInterface::class);
40+ Assert::isInstanceOf ($ this ->addressRepository , AddressRepositoryInterface::class);
41+
42+ $ customer = $ this ->customerRepository ->find ($ userSynchronization ->getCustomerId ());
43+ Assert::isInstanceOf ($ customer , CustomerInterface::class);
44+
45+ $ email = $ userSynchronization ->getEmail ();
46+
47+ $ addressId = $ userSynchronization ->getAddressId ();
48+ $ address = $ this ->getAddress ($ addressId );
49+
50+ $ resourceId = $ userSynchronization ->getUserComApiAwareResourceId ();
51+
52+ $ userComApiAwareResource = $ this ->userComApiAwareResourceProvider ->getApiAwareResourceById ($ resourceId );
53+ if (null === $ userComApiAwareResource ) {
54+ throw new UnrecoverableMessageHandlingException ('User.com API-aware resource not found ' );
7655 }
56+
57+ $ eventName = $ userSynchronization ->getEventName ();
58+
59+ $ this ->updateManager ->manageChange (
60+ $ eventName ,
61+ $ userComApiAwareResource ,
62+ $ customer ,
63+ $ address ,
64+ $ email ,
65+ $ userSynchronization ->getUserComCookie (),
66+ );
7767 }
7868
7969 private function getAddress (?int $ addressId ): ?AddressInterface
0 commit comments