public function postFlush(PostFlushEventArgs $args)
    {
        $change = false;

        $em = $args->getEntityManager();
        $uow = $args->getEntityManager()->getUnitOfWork();
        $result = $uow->getIdentityMap();
        if(isset($result[$this->targetClass])) {
            foreach ($result[$this->targetClass] as $entity) {
                $updated = $this->updateEntity($entity);
                if($updated) {
                    $change = true;
                }

                $propertyAccessor = PropertyAccess::createPropertyAccessor();
                $targetProperty = $propertyAccessor->getValue($entity, $this->targetProperty);

                if($targetProperty && $uow->getEntityState($targetProperty) !== UnitOfWork::STATE_MANAGED) {
                    $em->persist($targetProperty);
                    $change = true;
                }
            }
        }

        if($change) {
            $em->flush();
        }
    }
public function postFlush(PostFlushEventArgs $args)
    {
        $change = false;

        $em = $args->getEntityManager();
        $uow = $args->getEntityManager()->getUnitOfWork();
        $result = $uow->getIdentityMap();
        if(isset($result[$this->targetClass])) {
            foreach ($result[$this->targetClass] as $entity) {
                $updated = $this->updateEntity($entity);
                if($updated) {
                    $change = true;
                }

                $propertyAccessor = PropertyAccess::createPropertyAccessor();
                $targetProperty = $propertyAccessor->getValue($entity, $this->targetProperty);

                if($targetProperty && $uow->getEntityState($targetProperty) !== UnitOfWork::STATE_MANAGED) {
                    $em->persist($targetProperty);
                    $change = true;
                }
            }
        }

        if($change) {
            $em->flush();
        }
    }
public function postFlush ( PostFlushEventArgs $ args ) { $ change = false ; $ em = $ args -> getEntityManager ( ) ; $ uow = $ args -> getEntityManager ( ) -> getUnitOfWork ( ) ; $ result = $ uow -> getIdentityMap ( ) ; if ( isset ( $ result [ $ this -> targetClass ] ) ) { foreach ( $ result [ $ this -> targetClass ] as $ entity ) { $ updated = $ this -> updateEntity ( $ entity ) ; if ( $ updated ) { $ change = true ; } $ propertyAccessor = PropertyAccess :: createPropertyAccessor ( ) ; $ targetProperty = $ propertyAccessor -> getValue ( $ entity , $ this -> targetProperty ) ; if ( $ targetProperty && $ uow -> getEntityState ( $ targetProperty ) !== UnitOfWork :: STATE_MANAGED ) { $ em -> persist ( $ targetProperty ) ; $ change = true ; } } } if ( $ change ) { $ em -> flush ( ) ; } }
Check if entity is not up to date an trigger flush again if needed

@param PostFlushEventArgs $args
Check if entity is not up to date an trigger flush again if needed