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

        if (is_array($value) || (!$value instanceof CollectionProxy && $value instanceof Collection)) {
            $this->needSync[] = $relation;
        }

        // If the relation is a proxy, we test is the relation
        // has been lazy loaded, otherwise we'll just treat
        // the subset of newly added items.
        if ($value instanceof CollectionProxy && $value->isProxyInitialized()) {
            $this->needSync[] = $relation;
            //$value = $value->getUnderlyingCollection();
        }

        if ($value instanceof CollectionProxy && !$value->isProxyInitialized()) {
            $value = $value->getAddedItems();
        }

        // At this point $value should be either an array or an instance
        // of a collection class.
        if (!is_array($value) && !$value instanceof Collection) {
            throw new MappingException("'$relation' attribute should be array() or Collection");
        }

        $this->relationships[$relation] = $this->createSubAggregates($value, $relation);

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

        if (is_array($value) || (!$value instanceof CollectionProxy && $value instanceof Collection)) {
            $this->needSync[] = $relation;
        }

        // If the relation is a proxy, we test is the relation
        // has been lazy loaded, otherwise we'll just treat
        // the subset of newly added items.
        if ($value instanceof CollectionProxy && $value->isProxyInitialized()) {
            $this->needSync[] = $relation;
            //$value = $value->getUnderlyingCollection();
        }

        if ($value instanceof CollectionProxy && !$value->isProxyInitialized()) {
            $value = $value->getAddedItems();
        }

        // At this point $value should be either an array or an instance
        // of a collection class.
        if (!is_array($value) && !$value instanceof Collection) {
            throw new MappingException("'$relation' attribute should be array() or Collection");
        }

        $this->relationships[$relation] = $this->createSubAggregates($value, $relation);

        return true;
    }
protected function parseManyRelationship ( string $ relation ) : bool { if ( ! $ value = $ this -> parseForCommonValues ( $ relation ) ) { return true ; } if ( is_array ( $ value ) || ( ! $ value instanceof CollectionProxy && $ value instanceof Collection ) ) { $ this -> needSync [ ] = $ relation ; } // If the relation is a proxy, we test is the relation // has been lazy loaded, otherwise we'll just treat // the subset of newly added items. if ( $ value instanceof CollectionProxy && $ value -> isProxyInitialized ( ) ) { $ this -> needSync [ ] = $ relation ; //$value = $value->getUnderlyingCollection(); } if ( $ value instanceof CollectionProxy && ! $ value -> isProxyInitialized ( ) ) { $ value = $ value -> getAddedItems ( ) ; } // At this point $value should be either an array or an instance // of a collection class. if ( ! is_array ( $ value ) && ! $ value instanceof Collection ) { throw new MappingException ( "'$relation' attribute should be array() or Collection" ) ; } $ this -> relationships [ $ relation ] = $ this -> createSubAggregates ( $ value , $ relation ) ; return true ; }
Parse a 'many' relationship.

@param string $relation

@throws MappingException

@return bool
Parse a many relationship .