From 19d6509f731ee8786ec0e43b2d804d022fdab661 Mon Sep 17 00:00:00 2001 From: Mohamed Bouallegue Date: Tue, 21 Mar 2017 12:49:03 +0100 Subject: [PATCH] Minor changes to FractalController --- .../Mvc/Controllers/FractalController.php | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/PhalconRest/Mvc/Controllers/FractalController.php b/src/PhalconRest/Mvc/Controllers/FractalController.php index c65a778..db51a64 100644 --- a/src/PhalconRest/Mvc/Controllers/FractalController.php +++ b/src/PhalconRest/Mvc/Controllers/FractalController.php @@ -31,11 +31,6 @@ protected function createArrayResponse($array, $key) { $response = [$key => $array]; - return $this->createResponse($response); - } - - protected function createResponse($response) - { return $response; } @@ -43,32 +38,32 @@ protected function createOkResponse() { $response = ['result' => 'OK']; - return $this->createResponse($response); + return $response; } - protected function createItemOkResponse($item, $transformer, $resourceKey = null, $meta = null) + protected function createItemOkResponse($item, $transformer, $resourceKey = null, $meta = []) { $response = ['result' => 'OK']; $response += $this->createItemResponse($item, $transformer, $resourceKey, $meta); - return $this->createResponse($response); + return $response; } - protected function createItemResponse($item, $transformer, $resourceKey = null, $meta = null) + protected function createItemResponse($item, $transformer, $resourceKey = null, $meta = []) { $resource = new Item($item, $transformer, $resourceKey); $data = $this->fractal->createData($resource)->toArray(); - $response = array_merge($data, $meta ? $meta : []); + $response = array_merge($data, $meta); - return $this->createResponse($response); + return $response; } - protected function createCollectionResponse($collection, $transformer, $resourceKey = null, $meta = null) + protected function createCollectionResponse($collection, $transformer, $resourceKey = null, $meta = []) { $resource = new Collection($collection, $transformer, $resourceKey); $data = $this->fractal->createData($resource)->toArray(); - $response = array_merge($data, $meta ? $meta : []); + $response = array_merge($data, $meta); - return $this->createResponse($response); + return $response; } }