You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/filters.md
+96-6Lines changed: 96 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -152,7 +152,7 @@ constant directly.
152
152
153
153
The boolean filter allows you to search on boolean fields and values.
154
154
155
-
Syntax: `?property=[on|off|true|false|0|1]`
155
+
Syntax: `?property=[true|false|1|0]`
156
156
157
157
You can either use TRUE or true, the parameters are case insensitive.
158
158
@@ -422,15 +422,105 @@ It means that the filter will be **silently** ignored if the property:
422
422
Custom filters can be written by implementing the `ApiPlatform\Core\Api\FilterInterface`
423
423
interface.
424
424
425
-
If you use [custom data providers](data-providers.md), they must support filtering and be aware of active filters to work
426
-
properly.
425
+
API Platform provides a convenient way to create Doctrine ORM filters. If you use [custom data providers](data-providers.md),
426
+
you can still create filters by implementing the previously mentioned interface, but - as API Platform isn't aware of your
427
+
persistence system's internals - you have to create the filtering logic by yourself.
427
428
428
429
### Creating Custom Doctrine ORM Filters
429
430
430
-
Doctrine ORM filters must implement the `ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\FilterInterface`.
431
-
They can interact directly with the Doctrine `QueryBuilder`.
431
+
Doctrine filters can access to the HTTP request (Symfony's `Request` object) and to the `QueryBuilder` instance used to
432
+
retrieve data from the database. They are only applied to collections. If you want to deal with the DQL query generated
433
+
to retrieve items, or don't need to access the HTTP request, [extensions](extensions.md) are the way to go.
432
434
433
-
A convenient abstract class is also shipped with the bundle: `ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\AbstractFilter`
435
+
A Doctrine ORM filter is basically a class implementing the `ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\FilterInterface`.
436
+
API Platform includes a convenient abstract class implementing this interface and providing utility methods: `ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\AbstractFilter`
437
+
438
+
In the following example, we create a class to filter a collection by applying a regexp to a property. The `REGEXP` DQL
439
+
function used in this example can be found in the [`DoctrineExtensions`](https://github.com/beberlei/DoctrineExtensions)
440
+
library. This library must be properly installed and registered to use this example (works only with MySQL).
441
+
442
+
```php
443
+
<?php
444
+
445
+
// src/AppBundle/Filter/RegexpFilter.php
446
+
447
+
namespace AppBundle\Filter;
448
+
449
+
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\AbstractFilter;
450
+
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface;
Copy file name to clipboardExpand all lines: deployment/index.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
As an API Platform application is basically a standard Symfony application, [all Symfony deployment cookbooks](http://symfony.com/doc/current/cookbook/deployment/index.html)
4
4
apply.
5
5
6
-
However, API Platform also provide facilities to deploy applications trough containers and Platforms as a Service (PaaS):
6
+
However, API Platform also provide facilities to deploy applications through containers and Platforms as a Service (PaaS):
7
7
8
8
*[Deploying an API Platform App on Heroku](heroku.md)
0 commit comments