@@ -216,13 +216,13 @@ private function getIdForEntity(object $entity): ?string
216216
217217 foreach ($ properties as $ property ) {
218218 if ($ this ->isPropertyPrimaryKey ($ entity , $ property )) {
219- return (string )$ serializedData [$ property ];
219+ return (string ) $ serializedData [$ property ];
220220 }
221221 }
222222
223223 foreach (['getId ' , 'getUuid ' ] as $ method ) {
224224 if (in_array ($ method , $ methods )) {
225- return (string )$ entity ->$ method ();
225+ return (string ) $ entity ->$ method ();
226226 }
227227 }
228228
@@ -238,25 +238,39 @@ private function getIdentifierForEntity(object $entity): ?string
238238
239239 foreach ($ properties as $ property ) {
240240 if ($ this ->isPropertyIdentifier ($ entity , $ property )) {
241- return (string )$ serializedData [$ property ];
241+ return (string ) $ serializedData [$ property ];
242242 }
243243 }
244244
245245 foreach ($ methods as $ method ) {
246246 if ($ this ->isMethodIdentifier ($ entity , $ method )) {
247- return (string )$ entity ->$ method ();
247+ return (string ) $ entity ->$ method ();
248248 }
249249 }
250250
251251 foreach (['__toString ' , 'getName ' , 'getTitle ' , 'getId ' , 'getUuid ' ] as $ method ) {
252- if (in_array ($ method , $ methods )) {
253- return (string )$ entity ->$ method ();
252+ try {
253+ if (in_array ($ method , $ methods )) {
254+ $ value = $ entity ->$ method ();
255+ if ((is_object ($ value ) && $ this ->isEnum ($ value ))) {
256+ continue ;
257+ }
258+
259+ return (string )$ value ;
260+ }
261+ } catch (\Exception $ e ) {
262+ // Do nothing, it's probably not a valid method
254263 }
255264 }
256265
257266 return $ this ->getIdForEntity ($ entity );
258267 }
259268
269+ private function isEnum (object $ object ): bool
270+ {
271+ return (new ReflectionClass ($ object ))->isEnum ();
272+ }
273+
260274 private function getDataForDeletedEntity (object $ entity ): ?array
261275 {
262276 // Get the removals for the given entity class
0 commit comments