2016-07-09 10:02:25 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
* Easy!Appointments - Open Source Web Scheduler
|
|
|
|
*
|
|
|
|
* @package EasyAppointments
|
|
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
|
|
|
* @copyright Copyright (c) 2013 - 2016, Alex Tselegidis
|
|
|
|
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
|
|
|
|
* @link http://easyappointments.org
|
|
|
|
* @since v1.2.0
|
|
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
|
2016-07-09 14:14:08 +03:00
|
|
|
namespace EA\Engine\Api\V1\Processors;
|
2016-07-09 10:02:25 +03:00
|
|
|
|
2016-07-09 14:14:08 +03:00
|
|
|
class Paginate implements ProcessorsInterface {
|
2016-07-09 23:27:24 +03:00
|
|
|
public static function process(array &$response) {
|
2016-07-09 23:34:45 +03:00
|
|
|
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] : [];
|
2016-07-09 14:14:08 +03:00
|
|
|
}
|
2016-07-09 10:02:25 +03:00
|
|
|
}
|