protected function createIdentifierCollectionRelationship($object, RelationshipDefinition $definition, MappingContext $context): IdentifierCollectionRelationship
    {
        $relationship = new IdentifierCollectionRelationship();
        $collection   = $object->{$definition->getGetter()}();
        $dataLimit    = $definition->getDataLimit();

        if ($dataLimit > 0) {
            $collection = new \LimitIterator($collection, 0, $dataLimit);
        }

        $mapper = $context->getMapper();

        foreach ($collection as $relatedObject)
        {
            $resource = $mapper->toResourceIdentifier($relatedObject);

            $relationship->addIdentifier($resource);
        }

        return $relationship;
    }
protected function createIdentifierCollectionRelationship($object, RelationshipDefinition $definition, MappingContext $context): IdentifierCollectionRelationship
    {
        $relationship = new IdentifierCollectionRelationship();
        $collection   = $object->{$definition->getGetter()}();
        $dataLimit    = $definition->getDataLimit();

        if ($dataLimit > 0) {
            $collection = new \LimitIterator($collection, 0, $dataLimit);
        }

        $mapper = $context->getMapper();

        foreach ($collection as $relatedObject)
        {
            $resource = $mapper->toResourceIdentifier($relatedObject);

            $relationship->addIdentifier($resource);
        }

        return $relationship;
    }
protected function createIdentifierCollectionRelationship ( $ object , RelationshipDefinition $ definition , MappingContext $ context ) : IdentifierCollectionRelationship { $ relationship = new IdentifierCollectionRelationship ( ) ; $ collection = $ object -> { $ definition -> getGetter ( ) } ( ) ; $ dataLimit = $ definition -> getDataLimit ( ) ; if ( $ dataLimit > 0 ) { $ collection = new \ LimitIterator ( $ collection , 0 , $ dataLimit ) ; } $ mapper = $ context -> getMapper ( ) ; foreach ( $ collection as $ relatedObject ) { $ resource = $ mapper -> toResourceIdentifier ( $ relatedObject ) ; $ relationship -> addIdentifier ( $ resource ) ; } return $ relationship ; }
Create relationship contains a collection of resource-identifiers

@param  mixed                  $object
@param  RelationshipDefinition $definition
@param  MappingContext         $context
@return IdentifierCollectionRelationship
Create relationship contains a collection of resource - identifiers