mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-10 10:02:33 +03:00
Implemented pagination controller.
This commit is contained in:
parent
4189bcb459
commit
4a8111566d
1 changed files with 10 additions and 1 deletions
|
@ -15,6 +15,15 @@ namespace EA\Engine\Api\V1\Processors;
|
||||||
|
|
||||||
class Paginate implements ProcessorsInterface {
|
class Paginate implements ProcessorsInterface {
|
||||||
public static function process(array &$response) {
|
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] : [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue