PluginProbe
Assistant – Every Day Productivity Apps / trunk
Assistant – Every Day Productivity Apps vtrunk
1.5.5 trunk 0.1.0 0.2.0 0.2.1 0.2.2 0.3.0 0.3.1 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.6.0 0.7.0 0.7.0.2 0.7.0.3 0.7.0.4 0.7.0.5 0.7.0.6 0.7.0.7 0.7.0.8 0.7.0.9 0.7.1 1.0 All 71 releases
assistant / backend / src / System / Contracts / ControllerAbstract.php

ControllerAbstract.php in Assistant – Every Day Productivity Apps trunk, at backend/src/System/Contracts/ControllerAbstract.php

40 lines 836 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 }
40