Implemented minimize response processor and updated the ProcessorsInterface.

This commit is contained in:
Alex Tselegidis 2016-07-09 22:27:24 +02:00
parent bfc96409bc
commit 4189bcb459
6 changed files with 27 additions and 7 deletions

View File

@ -15,7 +15,7 @@ namespace EA\Engine\Api\V1\Processors;
class Filter implements ProcessorsInterface {
{
public static function process(array $response) {
public static function process(array &$response) {
}
}

View File

@ -14,7 +14,27 @@
namespace EA\Engine\Api\V1\Processors;
class Minimize implements ProcessorsInterface {
public static function process(array $response) {
public static function process(array &$response) {
if (!isset($_GET['fields'])) {
return;
}
$fields = explode(',', $_GET['fields']);
$temporaryResponse = [];
foreach ($response as &$entry) {
$temporaryEntry = [];
foreach ($fields as $field) {
if (isset($entry[$field])) {
$temporaryEntry[$field] = $entry[$field];
}
}
$temporaryResponse[] = $temporaryEntry;
}
$response = $temporaryResponse;
}
}

View File

@ -14,7 +14,7 @@
namespace EA\Engine\Api\V1\Processors;
class Paginate implements ProcessorsInterface {
public static function process(array $response) {
public static function process(array &$response) {
}
}

View File

@ -14,5 +14,5 @@
namespace EA\Engine\Api\V1\Processors;
interface ProcessorsInterface {
public static function process(array $response);
public static function process(array &$response);
}

View File

@ -14,7 +14,7 @@
namespace EA\Engine\Api\V1\Processors;
class Search implements ProcessorsInterface {
public static function process(array $response) {
public static function process(array &$response) {
}
}

View File

@ -14,7 +14,7 @@
namespace EA\Engine\Api\V1\Processors;
class Sort implements ProcessorsInterface {
public static function process(array $response) {
public static function process(array &$response) {
}
}