22
33[ ![ Latest Version on Packagist] [ ico-version ]] [ link-packagist ]
44[ ![ Software License] [ ico-license ]] ( LICENSE.md )
5- [ ![ Build Status] [ ico-travis ]] [ link-travis ]
5+ [ ![ Build Status] [ ico-github ]] [ link-github ]
66[ ![ Coverage Status] [ ico-scrutinizer ]] [ link-scrutinizer ]
77[ ![ Quality Score] [ ico-code-quality ]] [ link-code-quality ]
88[ ![ Total Downloads] [ ico-downloads ]] [ link-downloads ]
99
10- This is a simple component for CakePHP 4 which injects pagination information
10+ This is a simple component for CakePHP 4.2+ which injects pagination information
1111from CakePHP's Paginator into serialized JsonView and XmlView responses.
1212
13+ See ` 1.x ` and ` 2.x ` releases and branches of this plugin for support of previous versions of CakePHP before ` 4.2 ` .
14+
1315## Install
1416
1517Via Composer
@@ -18,10 +20,19 @@ Via Composer
1820$ composer require bcrowe/cakephp-api-pagination
1921```
2022
21- Load the plugin in your application' s ` bootstrap .php` file :
23+ Load the plugin by adding ` $this->addPlugin('BryanCrowe/ApiPagination'); ` to the ` bootsrap ` method in your project’ s ` src/Application .php` :
2224
2325``` php
24- Plugin::load('BryanCrowe/ApiPagination');
26+ public function bootstrap(): void
27+ {
28+ parent::bootstrap();
29+
30+ // ... bootstrap code ...
31+
32+ // load more plugins here
33+
34+ $this->addPlugin('BryanCrowe/ApiPagination');
35+ }
2536```
2637
2738## Usage
@@ -40,10 +51,9 @@ Then, go ahead and set your paginated view variable like so:
4051
4152``` php
4253$this->set('articles', $this->paginate($this->Articles));
43- $this->set('_serialize ', ['articles']);
54+ $this->viewBuilder()->setOption('serialize ', ['articles']);
4455```
45-
46- ** Note:** It is important that your ` _serialize ` variable is an array, e.g.
56+ ** Note:** It is important that your ` serialize ` option is an array, e.g.
4757` ['articles'] ` , so that your pagination information can be set under its own
4858pagination key.
4959
@@ -153,16 +163,16 @@ information.
153163
154164[ ico-version ] : https://img.shields.io/packagist/v/bcrowe/cakephp-api-pagination.svg?style=flat-square
155165[ ico-license ] : https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
156- [ ico-travis ] : https://img.shields.io/travis/ bcrowe/cakephp-api-pagination/master .svg?style=flat-square
166+ [ ico-github ] : https://github.com/ bcrowe/cakephp-api-pagination/workflows/CI/badge .svg
157167[ ico-scrutinizer ] : https://img.shields.io/scrutinizer/coverage/g/bcrowe/cakephp-api-pagination.svg?style=flat-square
158168[ ico-code-quality ] : https://img.shields.io/scrutinizer/g/bcrowe/cakephp-api-pagination.svg?style=flat-square
159169[ ico-downloads ] : https://img.shields.io/packagist/dt/bcrowe/cakephp-api-pagination.svg?style=flat-square
160170
161171[ link-packagist ] : https://packagist.org/packages/bcrowe/cakephp-api-pagination
162- [ link-travis ] : https://travis-ci.org /bcrowe/cakephp-api-pagination
172+ [ link-github ] : https://github.com /bcrowe/cakephp-api-pagination/actions
163173[ link-scrutinizer ] : https://scrutinizer-ci.com/g/bcrowe/cakephp-api-pagination/code-structure
164174[ link-code-quality ] : https://scrutinizer-ci.com/g/bcrowe/cakephp-api-pagination
165175[ link-downloads ] : https://packagist.org/packages/bcrowe/cakephp-api-pagination
166176[ link-author ] : https://github.com/bcrowe
167177[ 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
178+ [ link-dataviews ] : https ://book.cakephp.org/4 /en/views/json-and-xml-views.html#enabling-data-views-in-your-application
0 commit comments