|
1 | 1 | # Filters
|
2 | 2 |
|
3 | 3 | API Platform Core provides a generic system to apply filters on collections. Useful filters for the Doctrine ORM are provided
|
4 |
| -with the bundle. However the filter system is extensible enough to let you create custom filters that would fit your specific |
5 |
| -needs and for any data provider. |
| 4 | +with the library. You can also create custom filters that would fit your specific needs. |
| 5 | +You can also add filtering support to your custom [data providers](data-providers.md) by implementing interfaces provided |
| 6 | +by the library. |
6 | 7 |
|
7 | 8 | By default, all filters are disabled. They must be enabled explicitly.
|
8 | 9 |
|
9 |
| -When a filter is enabled, it is automatically documented as a `hydra:search` property in the collection response. It also automatically |
10 |
| -appears in the [NelmioApiDoc documentation](nelmio-api-doc.md) if it is available. |
| 10 | +When a filter is enabled, it is automatically documented as a `hydra:search` property in the collection response. It also |
| 11 | +automatically appears in the [NelmioApiDoc documentation](nelmio-api-doc.md) if it is available. |
11 | 12 |
|
12 | 13 | ## Search filter
|
13 | 14 |
|
14 | 15 | If Doctrine ORM support is enabled, adding filters is as easy as registering a filter service in your `app/config/services.yml`
|
15 |
| -file and adding an attribute to your resourcegi configuration. |
| 16 | +file and adding an attribute to your resource configuration. |
16 | 17 |
|
17 | 18 | The search filter supports `exact`, `partial`, `start`, `end`, and `word_start` matching strategies:
|
18 | 19 |
|
@@ -231,7 +232,7 @@ class Offer
|
231 | 232 |
|
232 | 233 | Given that the collection endpoint is `/offers`, you can filter offers by boolean with the following query: `/offers?isAvailableGenericallyInMyCountry=true`.
|
233 | 234 |
|
234 |
| -It will return all offers with `isAvailableGenericallyInMyCountry` equals `true`. |
| 235 | +It will return all offers where `isAvailableGenericallyInMyCountry` equals `true`. |
235 | 236 |
|
236 | 237 | ## Numeric Filter
|
237 | 238 |
|
@@ -309,9 +310,9 @@ or order offers by the product's release date: `http://localhost:8000/api/offers
|
309 | 310 |
|
310 | 311 | ## Enabling a filter for all properties of a resource
|
311 | 312 |
|
312 |
| -As we have seen in previous examples, properties where filters can be applied must be explicitly declared. But if you don't |
313 |
| -care about security and performance (e.g. an API with restricted access), it is also possible to enable built-in filters for |
314 |
| -all properties: |
| 313 | +As we have seen in previous examples, properties where filters can be applied must be explicitly declared. If you don't |
| 314 | +care about security and performance (e.g. an API with restricted access), it is also possible to enable built-in filters |
| 315 | +for all properties: |
315 | 316 |
|
316 | 317 | ```yaml
|
317 | 318 | # app/config/services.yml
|
|
0 commit comments