| @@ -1,39 +1,39 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace FL\Assistant\System\Contracts; | |
| 4 | - | |
| 5 | -use FL\Assistant\Data\Pager; | |
| 6 | - | |
| 7 | -abstract class ControllerAbstract { | |
| 8 | - | |
| 9 | - | |
| 10 | - /** | |
| 11 | - * @var string | |
| 12 | - */ | |
| 13 | - protected $namespace = 'fl-assistant/v1'; | |
| 14 | - | |
| 15 | - public function route( $route, array $config = [] ) { | |
| 16 | - register_rest_route( $this->namespace, $route, $config ); | |
| 17 | - } | |
| 18 | - | |
| 19 | - abstract public function register_routes(); | |
| 20 | - | |
| 21 | - /** | |
| 22 | - * Paginates the contents of an array | |
| 23 | - * | |
| 24 | - * @param array $data - complete list of items to paginate | |
| 25 | - * @param $limit | |
| 26 | - * @param $offset | |
| 27 | - * | |
| 28 | - * @return Pager | |
| 29 | - */ | |
| 30 | - public function paginate_array( array $data, $limit, $offset ) { | |
| 31 | - | |
| 32 | - $items = array_slice( $data, $offset, $limit, false ); | |
| 33 | - $total = count( $items ); | |
| 34 | - $limit = intval( $limit ); | |
| 35 | - $offset = intval( $offset ); | |
| 36 | - | |
| 37 | - return new Pager( $items, $total, $limit, $offset ); | |
| 38 | - } | |
| 39 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FL\Assistant\System\Contracts; | |
| 4 | + | |
| 5 | +use FL\Assistant\Data\Pager; | |
| 6 | + | |
| 7 | +abstract class ControllerAbstract { | |
| 8 | + | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * @var string | |
| 12 | + */ | |
| 13 | + protected $namespace = 'fl-assistant/v1'; | |
| 14 | + | |
| 15 | + public function route( $route, array $config = [] ) { | |
| 16 | + register_rest_route( $this->namespace, $route, $config ); | |
| 17 | + } | |
| 18 | + | |
| 19 | + abstract public function register_routes(); | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * Paginates the contents of an array | |
| 23 | + * | |
| 24 | + * @param array $data - complete list of items to paginate | |
| 25 | + * @param $limit | |
| 26 | + * @param $offset | |
| 27 | + * | |
| 28 | + * @return Pager | |
| 29 | + */ | |
| 30 | + public function paginate_array( array $data, $limit, $offset ) { | |
| 31 | + | |
| 32 | + $items = array_slice( $data, $offset, $limit, false ); | |
| 33 | + $total = count( $items ); | |
| 34 | + $limit = intval( $limit ); | |
| 35 | + $offset = intval( $offset ); | |
| 36 | + | |
| 37 | + return new Pager( $items, $total, $limit, $offset ); | |
| 38 | + } | |
| 39 | +} | |