@@ -18,10 +18,19 @@ Via Composer
18
18
$ composer require bcrowe/cakephp-api-pagination
19
19
```
20
20
21
- Load the plugin in your application' s ` bootstrap .php` file :
21
+ Load the plugin by adding ` $this->addPlugin('BryanCrowe/ApiPagination'); ` to the ` bootsrap ` method in your project’ s ` src/Application .php` :
22
22
23
23
``` php
24
- Plugin::load('BryanCrowe/ApiPagination');
24
+ public function bootstrap(): void
25
+ {
26
+ parent::bootstrap();
27
+
28
+ // ... bootstrap code ...
29
+
30
+ // load more plugins here
31
+
32
+ $this->addPlugin('BryanCrowe/ApiPagination');
33
+ }
25
34
```
26
35
27
36
## Usage
@@ -40,10 +49,9 @@ Then, go ahead and set your paginated view variable like so:
40
49
41
50
``` php
42
51
$this->set('articles', $this->paginate($this->Articles));
43
- $this->set('_serialize ', ['articles']);
52
+ $this->viewBuilder()->setOption('serialize ', ['articles']);
44
53
```
45
-
46
- ** Note:** It is important that your ` _serialize ` variable is an array, e.g.
54
+ ** Note:** It is important that your ` serialize ` option is an array, e.g.
47
55
` ['articles'] ` , so that your pagination information can be set under its own
48
56
pagination key.
49
57
@@ -165,4 +173,4 @@ information.
165
173
[ link-downloads ] : https://packagist.org/packages/bcrowe/cakephp-api-pagination
166
174
[ link-author ] : https://github.com/bcrowe
167
175
[ link-contributors ] : ../../contributors
168
- [ link-dataviews ] : http ://book.cakephp.org/3.0 /en/views/json-and-xml-views.html#enabling-data-views-in-your-application
176
+ [ link-dataviews ] : https ://book.cakephp.org/4 /en/views/json-and-xml-views.html#enabling-data-views-in-your-application
0 commit comments