Skip to content

Commit

Permalink
Merge pull request #9 from Happyr/add-meta
Browse files Browse the repository at this point in the history
Allow adding meta
  • Loading branch information
Nyholm authored Aug 28, 2019
2 parents 4ce37f1 + d591350 commit 6373f94
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ResponseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@ public function getFractal(): Manager
return $this->fractal;
}

public function createWithItem($item, AbstractTransformer $transformer): JsonResponse
public function createWithItem($item, AbstractTransformer $transformer, array $meta = []): JsonResponse
{
$resource = new Item($item, $transformer, $transformer->getResourceName());
$resource->setMeta($meta);
$rootScope = $this->fractal->createData($resource);

return $this->createWithArray($rootScope->toArray());
}

public function createWithCollection($collection, AbstractTransformer $transformer): JsonResponse
public function createWithCollection($collection, AbstractTransformer $transformer, array $meta = []): JsonResponse
{
$resource = new Collection($collection, $transformer, $transformer->getResourceName());
$resource->setMeta($meta);
if (null !== $this->paginator) {
$resource->setPaginator($this->paginator);
} elseif (null !== $this->cursor) {
Expand Down

0 comments on commit 6373f94

Please sign in to comment.