Skip to content

Commit adb20d7

Browse files
authored
Merge pull request #63 from tuyakhov/improve_pagination
Add Pagination class & improve page params handling
2 parents 5008b0c + 7e08c19 commit adb20d7

File tree

7 files changed

+88
-1783
lines changed

7 files changed

+88
-1783
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Thumbs.db
1717

1818
# composer itself is not needed
1919
composer.phar
20+
composer.lock
2021

2122
# Mac DS_Store Files
2223
.DS_Store

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ As the result:
168168
}
169169
}
170170
```
171+
Pagination
172+
---------------------------
173+
The `page` query parameter family is reserved for pagination.
174+
This library implements a page-based strategy and allows the usage of query parameters such as `page[number]` and `page[size]`
175+
Example: `http://yourdomain.com/users?page[number]=3&page[size]=10`
176+
171177
Enabling JSON API Input
172178
---------------------------
173179
To let the API accept input data in JSON API format, configure the [[yii\web\Request::$parsers|parsers]] property of the request application component to use the [[tuyakhov\jsonapi\JsonApiParser]] for JSON input
@@ -313,15 +319,8 @@ return [
313319
'urlManager' => [
314320
'rules' => [
315321
[
316-
'class' => 'yii\rest\UrlRule',
317-
'controller' => 'user',
318-
'extraPatterns' => [
319-
'GET {id}/<name:\w+>' => 'view-related',
320-
'PATCH {id}/relationships/<name:\w+>' => 'update-relationship',
321-
'DELETE {id}/relationships/<name:\w+>' => 'delete-relationship',
322-
'{id}/<name:\w+>' => 'options'
323-
],
324-
'except' => ['index'],
322+
'class' => 'tuyakhov\jsonapi\UrlRule',
323+
'controller' => ['user'],
325324
],
326325

327326
]

0 commit comments

Comments
 (0)