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
Note that `property` is used to document the Hydra view. You can also specify an [OpenAPI Parameter](https://api-platform.com/docs/references/OpenApi/Model/Parameter/) if needed.
1682
+
1683
+
### Alter the Operation via a parameter
1684
+
1685
+
A parameter can alter the current Operation context, to do so use a `ApiPlatform\State\ParameterProviderInterface`:
1686
+
1687
+
```php
1688
+
class GroupsParameterProvider implements ParameterProviderInterface {
1689
+
public function provider(Parameter $parameter, array $uriVariables = [], array $context = []): HttpOperation
A Parameter can also call a filter and works on filters that impact the data persistence layer (Doctrine ORM and ODM filters are supported). Let's assume, that we have an Order filter declared:
1723
+
1724
+
```yaml
1725
+
# config/services.yaml
1726
+
services:
1727
+
offer.order_filter:
1728
+
parent: 'api_platform.doctrine.orm.order_filter'
1729
+
arguments:
1730
+
$properties: { id: ~, name: ~ }
1731
+
$orderParameterName: order
1732
+
tags: [ 'api_platform.filter' ]
1733
+
```
1734
+
1735
+
We can use this filter specifying we want a query parameter with the `:property` placeholder:
1736
+
1737
+
```php
1738
+
namespace App\ApiResource;
1739
+
1740
+
#[GetCollection(
1741
+
uriTemplate: 'orders',
1742
+
parameters: [
1743
+
'order[:property]' => new QueryParameter(filter: 'offer.order_filter'),
1744
+
]
1745
+
)
1746
+
class Offer {
1747
+
public string $id;
1748
+
public string $name;
1749
+
}
1750
+
```
1751
+
1752
+
### Decorate a Doctrine filter
1753
+
1754
+
A filter that implements the `ApiPlatform\Doctrine\Common\Filter\PropertyAwareFilterInterface` interface can be decorated:
1755
+
1756
+
```php
1757
+
namespace App\Doctrine\Filter;
1758
+
1759
+
use ApiPlatform\Doctrine\Common\Filter\PropertyAwareFilterInterface;
1760
+
use ApiPlatform\Doctrine\Orm\Filter\FilterInterface;
1761
+
use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface;
1762
+
use ApiPlatform\Metadata\Operation;
1763
+
use Doctrine\ORM\QueryBuilder;
1764
+
use Symfony\Component\DependencyInjection\Attribute\Autowire;
1765
+
1766
+
final class SearchTextAndDateFilter implements FilterInterface
0 commit comments