add doc about filterHandler
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
8c0da98eb7
commit
3e888803af
|
@ -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`):
|
||||
|
|
Loading…
Reference in a new issue