1 | <?php |
||
13 | class ApiPaginationComponent extends Component |
||
14 | { |
||
15 | /** |
||
16 | * Default config. |
||
17 | * |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $_defaultConfig = [ |
||
21 | 'key' => 'pagination', |
||
22 | 'aliases' => [], |
||
23 | 'visible' => [] |
||
24 | ]; |
||
25 | |||
26 | /** |
||
27 | * Holds the paging information. |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $pagingInfo = []; |
||
32 | |||
33 | /** |
||
34 | * {@inheritDoc} |
||
35 | * |
||
36 | * @return array |
||
37 | */ |
||
38 | 3 | public function implementedEvents() |
|
42 | |||
43 | /** |
||
44 | * Injects the pagination info into the response if the current request is a |
||
45 | * JSON or XML request with pagination. |
||
46 | * |
||
47 | * @param Event $event The Controller.beforeRender event. |
||
48 | * @return void |
||
49 | */ |
||
50 | 18 | public function beforeRender(Event $event) |
|
70 | |||
71 | /** |
||
72 | * Aliases the default pagination keys to the new keys that the user defines |
||
73 | * in the config. |
||
74 | * |
||
75 | * @return void |
||
76 | */ |
||
77 | 6 | protected function setAliases() |
|
84 | |||
85 | /** |
||
86 | * Removes any pagination keys that haven't been defined as visible in the |
||
87 | * config. |
||
88 | * |
||
89 | * @return void |
||
90 | */ |
||
91 | 6 | protected function setVisibility() |
|
100 | |||
101 | /** |
||
102 | * Checks whether the current request is a JSON or XML request with |
||
103 | * pagination. |
||
104 | * |
||
105 | * @return bool True if JSON or XML with paging, otherwise false. |
||
106 | */ |
||
107 | 18 | protected function isPaginatedApiRequest() |
|
117 | } |
||
118 |