diff --git a/docs/entities/query.md b/docs/entities/query.md index 18e79d5..da3c794 100644 --- a/docs/entities/query.md +++ b/docs/entities/query.md @@ -114,6 +114,34 @@ $entities = $query->create() ->find(); ``` +In the context of a CRUD, filters are applied using [the method `useFilters`](https://gitnet.fr/murph/murph-core/src/branch/master/src/core/Repository/RepositoryQuery.php#L78-L99). +Integers, strings and booleans are automatically processed. Other types are passed to [the method `filterHandler`](https://gitnet.fr/murph/murph-core/src/branch/master/src/core/Repository/RepositoryQuery.php#L122-L124). + +You have to override it to manage them, example: + +```php-inline +// ... + +use App\Entity\Something; + +class MyEntityRepositoryQuery extends RepositoryQuery +{ + // ... + + public function filterHandler(string $name, $value): self + { + if ($name === 'something' && $value instanceof Something) { + $this + ->join('something', 's') + ->andWhere('s.id = :something') + ->setParameter('something', $value->getId()) + ; + } + } +} +``` + + ## Pager You can paginate entities (`Knp\Component\Pager\Pagination\PaginationInterface`):