|
@@ 112-118 (lines=7) @@
|
| 109 |
|
* |
| 110 |
|
* @return array The formatted array |
| 111 |
|
*/ |
| 112 |
|
protected function respondWithItem($item, $callback, Response $response) |
| 113 |
|
{ |
| 114 |
|
$resource = new Item($item, $callback); |
| 115 |
|
$rootScope = $this->fractal->createData($resource); |
| 116 |
|
|
| 117 |
|
return $this->respondWithArray($response, $rootScope->toArray()); |
| 118 |
|
} |
| 119 |
|
|
| 120 |
|
/** |
| 121 |
|
* Builds a collection of items from Fractal then hands off to the responder |
|
@@ 129-135 (lines=7) @@
|
| 126 |
|
* |
| 127 |
|
* @return array The formatted array |
| 128 |
|
*/ |
| 129 |
|
protected function respondWithCollection($collection, $callback, Response $response) |
| 130 |
|
{ |
| 131 |
|
$resource = new Collection($collection, $callback); |
| 132 |
|
$rootScope = $this->fractal->createData($resource); |
| 133 |
|
|
| 134 |
|
return $this->respondWithArray($response, $rootScope->toArray()); |
| 135 |
|
} |
| 136 |
|
|
| 137 |
|
/** |
| 138 |
|
* The final step where the formatted array is now sent back as a response in JSON form |