@@ -664,10 +664,10 @@ Four behaviors are available at the property level of the filter:
664
664
| Description | Strategy to set |
665
665
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------- |
666
666
| Use the default behavior of the DBMS | `null` |
667
- | Exclude items | `ApiPlatform\Doctrine\Orm \Filter\DateFilter ::EXCLUDE_NULL` (`exclude_null`) |
668
- | Consider items as oldest | `ApiPlatform\Doctrine\Orm \Filter\DateFilter ::INCLUDE_NULL_BEFORE` (`include_null_before`) |
669
- | Consider items as youngest | `ApiPlatform\Doctrine\Orm \Filter\DateFilter ::INCLUDE_NULL_AFTER` (`include_null_after`) |
670
- | Always include items | `ApiPlatform\Doctrine\Orm \Filter\DateFilter ::INCLUDE_NULL_BEFORE_AND_AFTER` (`include_null_before_and_after`) |
667
+ | Exclude items | `ApiPlatform\Doctrine\Common \Filter\DateFilterInterface ::EXCLUDE_NULL` (`exclude_null`) |
668
+ | Consider items as oldest | `ApiPlatform\Doctrine\Common \Filter\DateFilterInterface ::INCLUDE_NULL_BEFORE` (`include_null_before`) |
669
+ | Consider items as youngest | `ApiPlatform\Doctrine\Common \Filter\DateFilterInterface ::INCLUDE_NULL_AFTER` (`include_null_after`) |
670
+ | Always include items | `ApiPlatform\Doctrine\Common \Filter\DateFilterInterface ::INCLUDE_NULL_BEFORE_AND_AFTER` (`include_null_before_and_after`) |
671
671
672
672
For instance, exclude entries with a property value of `null` with the following service definition :
673
673
@@ -678,12 +678,13 @@ For instance, exclude entries with a property value of `null` with the following
678
678
// api/src/Entity/Offer.php
679
679
namespace App\E ntity;
680
680
681
+ use ApiPlatform\D octrine\C ommon\F ilter\D ateFilterInterface;
681
682
use ApiPlatform\M etadata\A piFilter;
682
683
use ApiPlatform\M etadata\A piResource;
683
684
use ApiPlatform\D octrine\O rm\F ilter\D ateFilter;
684
685
685
686
#[ApiResource]
686
- #[ApiFilter(DateFilter::class, properties: ['dateProperty' => DateFilter ::EXCLUDE_NULL])]
687
+ #[ApiFilter(DateFilter::class, properties: ['dateProperty' => DateFilterInterface ::EXCLUDE_NULL])]
687
688
class Offer
688
689
{
689
690
// ...
@@ -1970,6 +1971,7 @@ For example, let's define three data filters (`DateFilter`, `SearchFilter` and `
1970
1971
// api/src/Entity/DummyCar.php
1971
1972
namespace App\E ntity;
1972
1973
1974
+ use ApiPlatform\D octrine\C ommon\F ilter\D ateFilterInterface;
1973
1975
use ApiPlatform\M etadata\A piFilter;
1974
1976
use ApiPlatform\M etadata\A piResource;
1975
1977
use ApiPlatform\D octrine\O rm\F ilter\B ooleanFilter;
@@ -1981,7 +1983,7 @@ use Doctrine\ORM\Mapping as ORM;
1981
1983
1982
1984
#[ApiResource]
1983
1985
#[ApiFilter(BooleanFilter::class)]
1984
- #[ApiFilter(DateFilter::class, strategy: DateFilter ::EXCLUDE_NULL)]
1986
+ #[ApiFilter(DateFilter::class, strategy: DateFilterInterface ::EXCLUDE_NULL)]
1985
1987
#[ApiFilter(SearchFilter::class, properties: ['colors.prop' => 'ipartial', 'name' => 'partial'])]
1986
1988
#[ApiFilter(PropertyFilter::class, arguments: ['parameterName' => 'foobar'])]
1987
1989
#[ApiFilter(GroupFilter::class, arguments: ['parameterName' => 'foobargroups'])]
@@ -1998,10 +2000,10 @@ The `BooleanFilter` is applied to every `Boolean` property of the class. Indeed,
1998
2000
#[ApiFilter(BooleanFilter::class)]
1999
2001
` ` `
2000
2002
2001
- The `DateFilter` given here will be applied to every `Date` property of the `DummyCar` class with the `DateFilter ::EXCLUDE_NULL` strategy :
2003
+ The `DateFilter` given here will be applied to every `Date` property of the `DummyCar` class with the `DateFilterInterface ::EXCLUDE_NULL` strategy :
2002
2004
2003
2005
` ` ` php
2004
- #[ApiFilter(DateFilter::class, strategy: DateFilter ::EXCLUDE_NULL)]
2006
+ #[ApiFilter(DateFilter::class, strategy: DateFilterInterface ::EXCLUDE_NULL)]
2005
2007
` ` `
2006
2008
2007
2009
The `SearchFilter` here adds properties. The result is the exact same as the example with attributes on properties :
0 commit comments