Skip to content

Commit 4e126dc

Browse files
BatsaxIVJérémy Crapet
andauthored
docs: filters service declaration dedicated file (#440)
Co-authored-by: Jérémy Crapet <[email protected]>
1 parent 41937aa commit 4e126dc

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

core/filters.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ to a Resource in two ways:
2323

2424
1. Through the resource declaration, as the `filters` attribute.
2525

26-
For example having a filter service declaration:
26+
For example having a filter service declaration in `services.yaml`:
2727

2828
```yaml
2929
# api/config/services.yaml
@@ -34,12 +34,23 @@ to a Resource in two ways:
3434
arguments: [ { dateProperty: ~ } ]
3535
tags: [ 'api_platform.filter' ]
3636
# The following are mandatory only if a _defaults section is defined with inverted values.
37-
# You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the defaults section)
37+
# You may want to isolate filters in a dedicated file to avoid adding the following lines.
3838
autowire: false
3939
autoconfigure: false
4040
public: false
4141
```
4242
43+
Alternatively, you can choose to use a dedicated file to gather filters together:
44+
45+
```yaml
46+
# api/config/filters.yaml
47+
services:
48+
offer.date_filter:
49+
parent: 'api_platform.doctrine.orm.date_filter'
50+
arguments: [ { dateProperty: ~ } ]
51+
tags: [ 'api_platform.filter' ]
52+
```
53+
4354
We're linking the filter `offer.date_filter` with the resource like this:
4455

4556
[codeSelector]

0 commit comments

Comments
 (0)