@@ -50,7 +50,7 @@ public function __construct(private readonly IriConverterInterface|LegacyIriConv
5050 */
5151 public function preUpdate (PreUpdateEventArgs $ eventArgs ): void {
5252 $ changeSet = $ eventArgs ->getEntityChangeSet ();
53- $ objectManager = method_exists ( $ eventArgs, ' getObjectManager ' ) ? $ eventArgs ->getObjectManager () : $ eventArgs -> getEntityManager ();
53+ $ objectManager = $ eventArgs ->getObjectManager ();
5454 $ associationMappings = $ objectManager ->getClassMetadata (ClassUtils::getClass ($ eventArgs ->getObject ()))->getAssociationMappings ();
5555
5656 foreach ($ changeSet as $ key => $ value ) {
@@ -72,7 +72,12 @@ public function preUpdate(PreUpdateEventArgs $eventArgs): void {
7272 * Collects tags from inserted, updated and deleted entities, including relations.
7373 */
7474 public function onFlush (OnFlushEventArgs $ eventArgs ): void {
75- $ em = method_exists ($ eventArgs , 'getObjectManager ' ) ? $ eventArgs ->getObjectManager () : $ eventArgs ->getEntityManager ();
75+ $ em = $ eventArgs ->getObjectManager ();
76+
77+ if (!$ em instanceof EntityManagerInterface) {
78+ return ;
79+ }
80+
7681 $ uow = $ em ->getUnitOfWork ();
7782
7883 foreach ($ uow ->getScheduledEntityInsertions () as $ entity ) {
@@ -179,15 +184,7 @@ private function gatherRelationTags(EntityManagerInterface $em, object $entity):
179184 $ associationMappings = $ em ->getClassMetadata (ClassUtils::getClass ($ entity ))->getAssociationMappings ();
180185
181186 foreach ($ associationMappings as $ property => $ associationMapping ) {
182- // @phpstan-ignore-next-line
183- if (class_exists (AssociationMapping::class) && $ associationMapping instanceof AssociationMapping && ($ associationMapping ->targetEntity ?? null ) && !$ this ->resourceClassResolver ->isResourceClass ($ associationMapping ->targetEntity )) {
184- return ;
185- }
186-
187- // @phpstan-ignore-next-line
188- if (\is_array ($ associationMapping )
189- && \array_key_exists ('targetEntity ' , $ associationMapping )
190- && !$ this ->resourceClassResolver ->isResourceClass ($ associationMapping ['targetEntity ' ])) {
187+ if ($ associationMapping instanceof AssociationMapping && ($ associationMapping ->targetEntity ?? null ) && !$ this ->resourceClassResolver ->isResourceClass ($ associationMapping ->targetEntity )) {
191188 return ;
192189 }
193190
0 commit comments