1 | <?php |
||
12 | class ApiPaginationComponent extends Component |
||
13 | { |
||
14 | /** |
||
15 | * Default config. |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | protected $_defaultConfig = [ |
||
20 | 'key' => 'pagination', |
||
21 | 'aliases' => [], |
||
22 | 'visible' => [] |
||
23 | ]; |
||
24 | |||
25 | /** |
||
26 | * Holds the paging information array from the request. |
||
27 | * |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $pagingInfo = []; |
||
31 | |||
32 | /** |
||
33 | * Injects the pagination info into the response if the current request is a |
||
34 | * JSON or XML request with pagination. |
||
35 | * |
||
36 | * @param \Cake\Event\Event $event The Controller.beforeRender event. |
||
37 | 3 | * @return void |
|
38 | */ |
||
39 | 3 | public function beforeRender(Event $event) |
|
60 | 6 | ||
61 | 6 | /** |
|
62 | * Aliases the default pagination keys to the new keys that the user defines |
||
63 | 15 | * in the config. |
|
64 | 6 | * |
|
65 | 6 | * @return void |
|
66 | */ |
||
67 | 15 | protected function setAliases() |
|
74 | |||
75 | /** |
||
76 | * Removes any pagination keys that haven't been defined as visible in the |
||
77 | 6 | * config. |
|
78 | * |
||
79 | 6 | * @return void |
|
80 | 6 | */ |
|
81 | 6 | protected function setVisibility() |
|
90 | |||
91 | 6 | /** |
|
92 | * Checks whether the current request is a JSON or XML request with |
||
93 | 6 | * pagination. |
|
94 | 6 | * |
|
95 | 6 | * @return bool True if JSON or XML with paging, otherwise false. |
|
96 | 6 | */ |
|
97 | 6 | protected function isPaginatedApiRequest() |
|
107 | } |
||
108 |