Implemented pagination controller.

This commit is contained in:
Alex Tselegidis 2016-07-09 22:34:45 +02:00
parent 4189bcb459
commit 4a8111566d
1 changed files with 10 additions and 1 deletions

View File

@ -15,6 +15,15 @@ namespace EA\Engine\Api\V1\Processors;
class Paginate implements ProcessorsInterface {
public static function process(array &$response) {
if (!isset($_GET['page'])) {
return;
}
$page = (int)$_GET['page'];
$length = isset($_GET['length']) ? (int)$_GET['length'] : 20;
$chunks = array_chunk($response, $length);
$response = isset($chunks[$page]) ? $chunks[$page] : [];
}
}