EllipseSynergie\ApiResponse\AbstractResponse::withCollection PHP Method

withCollection() public method

Response for collection of items
public withCollection ( $data, callable | League\Fractal\TransformerAbstract $transformer, string $resourceKey = null, League\Fractal\Pagination\Cursor $cursor = null, array $meta = [], array $headers = [] ) : mixed
$data
$transformer callable | League\Fractal\TransformerAbstract
$resourceKey string
$cursor League\Fractal\Pagination\Cursor
$meta array
$headers array
return mixed
    public function withCollection($data, $transformer, $resourceKey = null, Cursor $cursor = null, $meta = [], array $headers = [])
    {
        $resource = new Collection($data, $transformer, $resourceKey);
        foreach ($meta as $metaKey => $metaValue) {
            $resource->setMetaValue($metaKey, $metaValue);
        }
        if (!is_null($cursor)) {
            $resource->setCursor($cursor);
        }
        $rootScope = $this->manager->createData($resource);
        return $this->withArray($rootScope->toArray(), $headers);
    }