Skip to content

Commit 1441d2c

Browse files
authored
Merge pull request #760 from soyuka/doc-extension
Change doc to reflect new extensions priorities
2 parents e2dd55d + fad34a1 commit 1441d2c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

core/extensions.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ final class CurrentUserExtension implements QueryCollectionExtensionInterface, Q
104104

105105
```
106106

107-
Finally register the custom extension:
107+
Finally, if you're not using the autoconfiguration, you have to register the custom extension with either of those tags:
108108

109109
```yaml
110110
# api/config/services.yaml
@@ -114,13 +114,23 @@ services:
114114

115115
'App\Doctrine\CurrentUserExtension':
116116
tags:
117-
- { name: api_platform.doctrine.orm.query_extension.collection, priority: 9 }
117+
- { name: api_platform.doctrine.orm.query_extension.collection }
118118
- { name: api_platform.doctrine.orm.query_extension.item }
119119
```
120120
121-
Thanks to the `api_platform.doctrine.orm.query_extension.collection` tag, API Platform will register this service as a collection extension. The `api_platform.doctrine.orm.query_extension.item` do the same thing for items.
121+
The `api_platform.doctrine.orm.query_extension.collection` tag will register this service as a collection extension.
122+
The `api_platform.doctrine.orm.query_extension.item` do the same thing for items.
122123

123-
Notice the priority level for the `api_platform.doctrine.orm.query_extension.collection` tag. When an extension implements the `ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryResultCollectionExtensionInterface` or the `ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryResultItemExtensionInterface` interface to return results by itself, any lower priority extension will not be executed. Because the pagination is enabled by default with a priority of 8, the priority of the `app.doctrine.orm.query_extension.current_user` service must be at least 9 to ensure its execution.
124+
Note that your extensions should have a positive priority if defined. Internal extensions have negative priorities, for reference:
125+
126+
| Service name | Priority | Class |
127+
|------------------------------------------------------------|------|---------------------------------------------------------|
128+
| api_platform.doctrine.orm.query_extension.eager_loading (collection) | -8 | ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\EagerLoadingExtension |
129+
| api_platform.doctrine.orm.query_extension.eager_loading (item) | -8 | ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\EagerLoadingExtension |
130+
| api_platform.doctrine.orm.query_extension.filter | -16 | ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\FilterExtension |
131+
| api_platform.doctrine.orm.query_extension.filter_eager_loading | -17 | ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\FilterEagerLoadingExtension |
132+
| api_platform.doctrine.orm.query_extension.order | -32 | ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\OrderExtension |
133+
| api_platform.doctrine.orm.query_extension.pagination | -64 | ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\PaginationExtension |
124134

125135
#### Blocking Anonymous Users
126136

0 commit comments

Comments
 (0)