@@ -108,13 +108,19 @@ public function updateWithUserKey(
108108 );
109109
110110 $ this ->userApi ->mergeUsers ($ apiAwareResource , $ userByEmailFromForm ['id ' ], [$ userFoundByKey ['id ' ]]);
111- $ this ->changeCookieWithEvent ($ user , $ apiAwareResource , $ eventName , $ payload );
111+ if (is_array ($ user ) && isset ($ user ['email ' ]) && is_string ($ user ['email ' ])) {
112+ $ this ->sendEvent ($ apiAwareResource , $ user ['email ' ], $ eventName , $ payload );
113+ }
114+ $ this ->changeCookie ($ user );
112115
113116 return $ user ;
114117 }
115118
116119 $ user = $ this ->userApi ->createUser ($ apiAwareResource , $ payload );
117- $ this ->changeCookieWithEvent ($ user , $ apiAwareResource , $ eventName , $ payload );
120+
121+ if (is_array ($ user ) && isset ($ user ['email ' ]) && is_string ($ user ['email ' ])) {
122+ $ this ->sendEvent ($ apiAwareResource , $ user ['email ' ], $ eventName , $ payload );
123+ } $ this ->changeCookie ($ user );
118124
119125 return $ user ;
120126 }
@@ -154,16 +160,16 @@ private function updateForUserWithoutEmail(
154160 $ this ->userApi ->mergeUsers ($ apiAwareResource , $ customerFoundByEmail ['id ' ], [$ userFromUserKey ['id ' ]]);
155161 }
156162
157- $ this ->changeCookieWithEvent ($ user , $ apiAwareResource , $ eventName );
163+ if (is_array ($ user ) && isset ($ user ['email ' ]) && is_string ($ user ['email ' ])) {
164+ $ this ->sendEvent ($ apiAwareResource , $ user ['email ' ], $ eventName , $ payload );
165+ }
166+ $ this ->changeCookie ($ user );
158167
159168 return $ user ;
160169 }
161170
162- public function changeCookieWithEvent (
171+ public function changeCookie (
163172 ?array $ user ,
164- UserComApiAwareInterface $ apiAwareResource ,
165- string $ eventName ,
166- ?array $ payload = null ,
167173 ): void {
168174 if (false === is_array ($ user ) ||
169175 false === array_key_exists ('id ' , $ user ) ||
@@ -173,6 +179,5 @@ public function changeCookieWithEvent(
173179 }
174180
175181 $ this ->cookieManager ->setUserComCookie ($ user ['user_key ' ]);
176- $ this ->sendEvent ($ apiAwareResource , $ user ['email ' ], $ eventName , $ payload );
177182 }
178183}
0 commit comments