protected function parseSingleRelationship(string $relation): bool
    {
        if (!$value = $this->parseForCommonValues($relation)) {
            return true;
        }

        if ($value instanceof Collection || is_array($value) || $value instanceof CollectionProxy) {
            throw new MappingException("Entity's attribute $relation should not be array, or collection");
        }

        if ($value instanceof LazyLoadingInterface && !$value->isProxyInitialized()) {
            $this->relationships[$relation] = [];

            return true;
        }

        // If the attribute is a loaded proxy, swap it for its
        // loaded entity.
        if ($value instanceof LazyLoadingInterface && $value->isProxyInitialized()) {
            $value = $value->getWrappedValueHolderValue();
        }

        if ($this->isParentOrRoot($value)) {
            $this->relationships[$relation] = [];

            return true;
        }

        // At this point, we can assume the attribute is an Entity instance
        // so we'll treat it as such.
        $subAggregate = $this->createSubAggregate($value, $relation);

        // Even if it's a single entity, we'll store it as an array
        // just for consistency with other relationships
        $this->relationships[$relation] = [$subAggregate];

        // We always need to check a loaded relation is in sync
        // with its local key
        $this->needSync[] = $relation;

        return true;
    }
protected function parseSingleRelationship(string $relation): bool
    {
        if (!$value = $this->parseForCommonValues($relation)) {
            return true;
        }

        if ($value instanceof Collection || is_array($value) || $value instanceof CollectionProxy) {
            throw new MappingException("Entity's attribute $relation should not be array, or collection");
        }

        if ($value instanceof LazyLoadingInterface && !$value->isProxyInitialized()) {
            $this->relationships[$relation] = [];

            return true;
        }

        // If the attribute is a loaded proxy, swap it for its
        // loaded entity.
        if ($value instanceof LazyLoadingInterface && $value->isProxyInitialized()) {
            $value = $value->getWrappedValueHolderValue();
        }

        if ($this->isParentOrRoot($value)) {
            $this->relationships[$relation] = [];

            return true;
        }

        // At this point, we can assume the attribute is an Entity instance
        // so we'll treat it as such.
        $subAggregate = $this->createSubAggregate($value, $relation);

        // Even if it's a single entity, we'll store it as an array
        // just for consistency with other relationships
        $this->relationships[$relation] = [$subAggregate];

        // We always need to check a loaded relation is in sync
        // with its local key
        $this->needSync[] = $relation;

        return true;
    }
protected function parseSingleRelationship ( string $ relation ) : bool { if ( ! $ value = $ this -> parseForCommonValues ( $ relation ) ) { return true ; } if ( $ value instanceof Collection || is_array ( $ value ) || $ value instanceof CollectionProxy ) { throw new MappingException ( "Entity's attribute $relation should not be array, or collection" ) ; } if ( $ value instanceof LazyLoadingInterface && ! $ value -> isProxyInitialized ( ) ) { $ this -> relationships [ $ relation ] = [ ] ; return true ; } // If the attribute is a loaded proxy, swap it for its // loaded entity. if ( $ value instanceof LazyLoadingInterface && $ value -> isProxyInitialized ( ) ) { $ value = $ value -> getWrappedValueHolderValue ( ) ; } if ( $ this -> isParentOrRoot ( $ value ) ) { $ this -> relationships [ $ relation ] = [ ] ; return true ; } // At this point, we can assume the attribute is an Entity instance // so we'll treat it as such. $ subAggregate = $ this -> createSubAggregate ( $ value , $ relation ) ; // Even if it's a single entity, we'll store it as an array // just for consistency with other relationships $ this -> relationships [ $ relation ] = [ $ subAggregate ] ; // We always need to check a loaded relation is in sync // with its local key $ this -> needSync [ ] = $ relation ; return true ; }
Parse a 'single' relationship.

@param string $relation

@throws MappingException

@return bool
Parse a single relationship .