original_string: 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();
          }
      }
code: 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();
          }
      }
code_tokens: 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 ( ) ; } }
docstring: Check if entity is not up to date an trigger flush again if needed
  
  @param PostFlushEventArgs $args
docstring_tokens: Check if entity is not up to date an trigger flush again if needed