33namespace  SumoCoders \FrameworkCoreBundle \DoctrineListener ;
44
55use  Doctrine \Bundle \DoctrineBundle \Attribute \AsDoctrineListener ;
6+ use  Doctrine \Common \Util \ClassUtils ;
67use  Doctrine \ORM \EntityManagerInterface ;
78use  Doctrine \ORM \Event \PostPersistEventArgs ;
89use  Doctrine \ORM \Event \PostRemoveEventArgs ;
3132class  DoctrineAuditListener
3233{
3334    public  function  __construct (
34-         private  readonly  AuditLogger $ auditLogger
35+         private  readonly  AuditLogger          $ auditLogger
3536        private  readonly  SerializerInterface $ serializer
36-         private  $ removals
37+         private                                $ removals
3738    ) {
3839    }
3940
@@ -214,13 +215,13 @@ private function getIdForEntity(object $entity): ?string
214215
215216        foreach  ($ propertiesas  $ property
216217            if  ($ this isPropertyPrimaryKey ($ entity$ property
217-                 return  (string )  $ serializedData$ property
218+                 return  (string )$ serializedData$ property
218219            }
219220        }
220221
221222        foreach  (['getId ' , 'getUuid ' ] as  $ method
222223            if  (in_array ($ method$ methods
223-                 return  (string )  $ entity$ method
224+                 return  (string )$ entity$ method
224225            }
225226        }
226227
@@ -236,19 +237,19 @@ private function getIdentifierForEntity(object $entity): ?string
236237
237238        foreach  ($ propertiesas  $ property
238239            if  ($ this isPropertyIdentifier ($ entity$ property
239-                 return  (string )  $ serializedData$ property
240+                 return  (string )$ serializedData$ property
240241            }
241242        }
242243
243244        foreach  ($ methodsas  $ method
244245            if  ($ this isMethodIdentifier ($ entity$ method
245-                 return  (string )  $ entity$ method
246+                 return  (string )$ entity$ method
246247            }
247248        }
248249
249250        foreach  (['__toString ' , 'getName ' , 'getTitle ' , 'getId ' , 'getUuid ' ] as  $ method
250251            if  (in_array ($ method$ methods
251-                 return  (string )  $ entity$ method
252+                 return  (string )$ entity$ method
252253            }
253254        }
254255
@@ -303,7 +304,8 @@ private function classHasAttribute(
303304        object $ entity
304305        string  $ attribute
305306    ): bool  {
306-         $ reflectionClassnew  ReflectionClass ($ entity
307+         $ classStringgetRealClass ($ entity
308+         $ reflectionClassnew  ReflectionClass ($ classString
307309        return  count ($ reflectionClassgetAttributes ($ attribute0 ;
308310    }
309311
@@ -312,7 +314,8 @@ private function propertyHasAttribute(
312314        string  $ property
313315        string  $ attribute
314316    ): bool  {
315-         $ reflectionClassnew  ReflectionClass ($ entity
317+         $ classStringgetRealClass ($ entity
318+         $ reflectionClassnew  ReflectionClass ($ classString
316319        $ properties$ reflectionClassgetProperties ();
317320        foreach  ($ propertiesas  $ item
318321            if  (
@@ -331,7 +334,8 @@ private function methodHasAttribute(
331334        string  $ method
332335        string  $ attribute
333336    ): bool  {
334-         $ reflectionClassnew  ReflectionClass ($ entity
337+         $ classStringgetRealClass ($ entity
338+         $ reflectionClassnew  ReflectionClass ($ classString
335339        $ methods$ reflectionClassgetMethods ();
336340        foreach  ($ methodsas  $ item
337341            if  (
@@ -359,7 +363,8 @@ private function showPropertyDataForEntity(object $entity): bool
359363
360364    private  function  showDataForEntity (object $ entitybool 
361365    {
362-         $ reflectionClassnew  ReflectionClass ($ entity
366+         $ classStringgetRealClass ($ entity
367+         $ reflectionClassnew  ReflectionClass ($ classString
363368        if  ($ reflectionClassgetAttributes (DisplayAllEntityFieldWithDataInLog::class)) {
364369            return  true ;
365370        }
@@ -369,7 +374,8 @@ private function showDataForEntity(object $entity): bool
369374
370375    private  function  getMethods (object $ entityarray 
371376    {
372-         $ reflectionClassnew  ReflectionClass ($ entity
377+         $ classStringgetRealClass ($ entity
378+         $ reflectionClassnew  ReflectionClass ($ classString
373379        $ methods$ reflectionClassgetMethods ();
374380
375381        return  array_map (
@@ -380,7 +386,8 @@ private function getMethods(object $entity): array
380386
381387    private  function  getProperties (object $ entityarray 
382388    {
383-         $ reflectionClassnew  ReflectionClass ($ entity
389+         $ classStringgetRealClass ($ entity
390+         $ reflectionClassnew  ReflectionClass ($ classString
384391        $ properties$ reflectionClassgetProperties ();
385392
386393        return  array_map (
0 commit comments