private function checkHasOneRelation($entity, $relation)
    {
        $objectHashId     = $this->entityRegistry->getObjectHashId($entity);
        $varObjName       = $relation->varObjectName();
        $varReferenceName = $relation->varReferenceName();

        $currentRelation  = $this->getValue($entity, $varObjName);
        $originalRelation = $this->getValue($this->entityRegistry->getOriginal($entity), $varObjName);

        if (empty($currentRelation)) {
            // Current entity has no relation
            if (!empty($originalRelation)) {
                // Original had a relation, so relation was removed
                $this->scheduleForDeletion($originalRelation);
            }

            return;
        }

        // Current entity has a relation
        $currentRelationHash = $this->entityRegistry->getObjectHashId($currentRelation);

        if (isset($this->scheduledForDeletion[$objectHashId]) && $relation->cascadeDelete()) {
            $this->scheduleForDeletion($currentRelation);
        }

        if (empty($originalRelation)) {
            // Original had no relation, so relation was newly created
            $this->scheduleRelationForInsertion($entity, $currentRelation, $varReferenceName);

            return;
        }

        $originalRelationHash = $this->entityRegistry->getObjectHashId($originalRelation);

        if ($currentRelationHash != $originalRelationHash) {
            // Relation was exchanged
            $this->scheduleForDeletion($originalRelation);
            $this->scheduleRelationForInsertion($entity, $currentRelation, $varReferenceName);
        }
    }
private function checkHasOneRelation($entity, $relation)
    {
        $objectHashId     = $this->entityRegistry->getObjectHashId($entity);
        $varObjName       = $relation->varObjectName();
        $varReferenceName = $relation->varReferenceName();

        $currentRelation  = $this->getValue($entity, $varObjName);
        $originalRelation = $this->getValue($this->entityRegistry->getOriginal($entity), $varObjName);

        if (empty($currentRelation)) {
            // Current entity has no relation
            if (!empty($originalRelation)) {
                // Original had a relation, so relation was removed
                $this->scheduleForDeletion($originalRelation);
            }

            return;
        }

        // Current entity has a relation
        $currentRelationHash = $this->entityRegistry->getObjectHashId($currentRelation);

        if (isset($this->scheduledForDeletion[$objectHashId]) && $relation->cascadeDelete()) {
            $this->scheduleForDeletion($currentRelation);
        }

        if (empty($originalRelation)) {
            // Original had no relation, so relation was newly created
            $this->scheduleRelationForInsertion($entity, $currentRelation, $varReferenceName);

            return;
        }

        $originalRelationHash = $this->entityRegistry->getObjectHashId($originalRelation);

        if ($currentRelationHash != $originalRelationHash) {
            // Relation was exchanged
            $this->scheduleForDeletion($originalRelation);
            $this->scheduleRelationForInsertion($entity, $currentRelation, $varReferenceName);
        }
    }
private function checkHasOneRelation ( $ entity , $ relation ) { $ objectHashId = $ this -> entityRegistry -> getObjectHashId ( $ entity ) ; $ varObjName = $ relation -> varObjectName ( ) ; $ varReferenceName = $ relation -> varReferenceName ( ) ; $ currentRelation = $ this -> getValue ( $ entity , $ varObjName ) ; $ originalRelation = $ this -> getValue ( $ this -> entityRegistry -> getOriginal ( $ entity ) , $ varObjName ) ; if ( empty ( $ currentRelation ) ) { // Current entity has no relation if ( ! empty ( $ originalRelation ) ) { // Original had a relation, so relation was removed $ this -> scheduleForDeletion ( $ originalRelation ) ; } return ; } // Current entity has a relation $ currentRelationHash = $ this -> entityRegistry -> getObjectHashId ( $ currentRelation ) ; if ( isset ( $ this -> scheduledForDeletion [ $ objectHashId ] ) && $ relation -> cascadeDelete ( ) ) { $ this -> scheduleForDeletion ( $ currentRelation ) ; } if ( empty ( $ originalRelation ) ) { // Original had no relation, so relation was newly created $ this -> scheduleRelationForInsertion ( $ entity , $ currentRelation , $ varReferenceName ) ; return ; } $ originalRelationHash = $ this -> entityRegistry -> getObjectHashId ( $ originalRelation ) ; if ( $ currentRelationHash != $ originalRelationHash ) { // Relation was exchanged $ this -> scheduleForDeletion ( $ originalRelation ) ; $ this -> scheduleRelationForInsertion ( $ entity , $ currentRelation , $ varReferenceName ) ; } }
Check for changes in a hasOne relation

We are handling a Detail and checking the Extra.
Extra->detailId = Detail->id

@param   object $entity   The entity
@param   HasOne $relation The relation

@return  void
Check for changes in a hasOne relation