Skip to content

Doctrine ORM Filters - service declaration #440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions core/filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ to a Resource in two ways:

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

For example having a filter service declaration:
For example having a filter service declaration in `services.yaml`:

```yaml
# api/config/services.yaml
Expand All @@ -34,12 +34,23 @@ to a Resource in two ways:
arguments: [ { dateProperty: ~ } ]
tags: [ 'api_platform.filter' ]
# The following are mandatory only if a _defaults section is defined with inverted values.
# You may want to isolate filters in a dedicated file to avoid adding the following lines (by adding them in the defaults section)
# You may want to isolate filters in a dedicated file to avoid adding the following lines.
autowire: false
autoconfigure: false
public: false
```

Alternatively, you can choose to use a dedicated file to gather filters together:

```yaml
# api/config/filters.yaml
services:
offer.date_filter:
parent: 'api_platform.doctrine.orm.date_filter'
arguments: [ { dateProperty: ~ } ]
tags: [ 'api_platform.filter' ]
```

We're linking the filter `offer.date_filter` with the resource like this:

[codeSelector]
Expand Down