private function hydrateToManyRelation($entity, $name, $targetEntity, $data, $scope)
    {
        if (!is_array($data)) {
            throw RestException::missingData($scope);
        }

        $this->setObjectProperty($entity, $name,
            new ArrayCollection(array_map(
                function($item, $index) use ($targetEntity, $scope) {
                    return $this->hydrateRelationData($targetEntity, $item, $scope.'['.$index.']');
                },
                $data,
                array_keys($data)
            ))
        );
    }
private function hydrateToManyRelation($entity, $name, $targetEntity, $data, $scope)
    {
        if (!is_array($data)) {
            throw RestException::missingData($scope);
        }

        $this->setObjectProperty($entity, $name,
            new ArrayCollection(array_map(
                function($item, $index) use ($targetEntity, $scope) {
                    return $this->hydrateRelationData($targetEntity, $item, $scope.'['.$index.']');
                },
                $data,
                array_keys($data)
            ))
        );
    }
private function hydrateToManyRelation ( $ entity , $ name , $ targetEntity , $ data , $ scope ) { if ( ! is_array ( $ data ) ) { throw RestException :: missingData ( $ scope ) ; } $ this -> setObjectProperty ( $ entity , $ name , new ArrayCollection ( array_map ( function ( $ item , $ index ) use ( $ targetEntity , $ scope ) { return $ this -> hydrateRelationData ( $ targetEntity , $ item , $ scope . '[' . $ index . ']' ) ; } , $ data , array_keys ( $ data ) ) ) ) ; }
Hydrate one relation.

@param object $entity
@param string $name          Relation name
@param string $targetEntity  Doctrine relation class name
@param mixed  $data
@param string $scope

@return object
@throws RestException
Hydrate one relation .