private function updateEntity($entity)
    {
        $change = false;

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

        // if entity state is still proxy, we try to load its entity to make sure that target property is correct
        if($entity instanceof Proxy && $targetProperty === null) {
            $this->loadEntity($entity);
            $targetProperty = $propertyAccessor->getValue($entity, $this->targetProperty);
        }

        if($targetProperty) {
            // update id property
            $idProperty = $propertyAccessor->getValue($entity, $this->idProperty);
            $id = $propertyAccessor->getValue($targetProperty, 'id');
            if($idProperty != $id) {
                $propertyAccessor->setValue($entity, $this->idProperty, $id);
                $change = true;
            }

            // update class property
            $classProperty = $propertyAccessor->getValue($entity, $this->classProperty);
            $class = $this->targetClassResolver->resolveClass($targetProperty);
            if($classProperty != $class) {
                $propertyAccessor->setValue($entity, $this->classProperty, $class);
                $change = true;
            }
        } else {
            if(null !== $propertyAccessor->getValue($entity, $this->idProperty)) {
                $propertyAccessor->setValue($entity, $this->idProperty, null);
                $change = true;
            }

            if(null !== $propertyAccessor->getValue($entity, $this->classProperty)) {
                $propertyAccessor->setValue($entity, $this->classProperty, null);
                $change = true;
            }
        }

        return $change;
    }
private function updateEntity($entity)
    {
        $change = false;

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

        // if entity state is still proxy, we try to load its entity to make sure that target property is correct
        if($entity instanceof Proxy && $targetProperty === null) {
            $this->loadEntity($entity);
            $targetProperty = $propertyAccessor->getValue($entity, $this->targetProperty);
        }

        if($targetProperty) {
            // update id property
            $idProperty = $propertyAccessor->getValue($entity, $this->idProperty);
            $id = $propertyAccessor->getValue($targetProperty, 'id');
            if($idProperty != $id) {
                $propertyAccessor->setValue($entity, $this->idProperty, $id);
                $change = true;
            }

            // update class property
            $classProperty = $propertyAccessor->getValue($entity, $this->classProperty);
            $class = $this->targetClassResolver->resolveClass($targetProperty);
            if($classProperty != $class) {
                $propertyAccessor->setValue($entity, $this->classProperty, $class);
                $change = true;
            }
        } else {
            if(null !== $propertyAccessor->getValue($entity, $this->idProperty)) {
                $propertyAccessor->setValue($entity, $this->idProperty, null);
                $change = true;
            }

            if(null !== $propertyAccessor->getValue($entity, $this->classProperty)) {
                $propertyAccessor->setValue($entity, $this->classProperty, null);
                $change = true;
            }
        }

        return $change;
    }
private function updateEntity ( $ entity ) { $ change = false ; $ propertyAccessor = PropertyAccess :: createPropertyAccessor ( ) ; $ targetProperty = $ propertyAccessor -> getValue ( $ entity , $ this -> targetProperty ) ; // if entity state is still proxy, we try to load its entity to make sure that target property is correct if ( $ entity instanceof Proxy && $ targetProperty === null ) { $ this -> loadEntity ( $ entity ) ; $ targetProperty = $ propertyAccessor -> getValue ( $ entity , $ this -> targetProperty ) ; } if ( $ targetProperty ) { // update id property $ idProperty = $ propertyAccessor -> getValue ( $ entity , $ this -> idProperty ) ; $ id = $ propertyAccessor -> getValue ( $ targetProperty , 'id' ) ; if ( $ idProperty != $ id ) { $ propertyAccessor -> setValue ( $ entity , $ this -> idProperty , $ id ) ; $ change = true ; } // update class property $ classProperty = $ propertyAccessor -> getValue ( $ entity , $ this -> classProperty ) ; $ class = $ this -> targetClassResolver -> resolveClass ( $ targetProperty ) ; if ( $ classProperty != $ class ) { $ propertyAccessor -> setValue ( $ entity , $ this -> classProperty , $ class ) ; $ change = true ; } } else { if ( null !== $ propertyAccessor -> getValue ( $ entity , $ this -> idProperty ) ) { $ propertyAccessor -> setValue ( $ entity , $ this -> idProperty , null ) ; $ change = true ; } if ( null !== $ propertyAccessor -> getValue ( $ entity , $ this -> classProperty ) ) { $ propertyAccessor -> setValue ( $ entity , $ this -> classProperty , null ) ; $ change = true ; } } return $ change ; }
Update entity values

@param object $entity
@return boolean
Update entity values