Skip to content

Commit 9602a75

Browse files
authored
Merge pull request #514 from Selion05/2.2
Update filters.md
2 parents 4b08818 + fe1f2c9 commit 9602a75

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

core/filters.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,14 +665,22 @@ library. This library must be properly installed and registered to use this exam
665665
666666
namespace App\Filter;
667667
668-
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\AbstractFilter;
668+
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\AbstractContextAwareFilter;
669669
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface;
670670
use Doctrine\ORM\QueryBuilder;
671671
672-
final class RegexpFilter extends AbstractFilter
672+
final class RegexpFilter extends AbstractContextAwareFilter
673673
{
674674
protected function filterProperty(string $property, $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, string $operationName = null)
675675
{
676+
// otherwise filter is applied to order and page as well
677+
if (
678+
!$this->isPropertyEnabled($property, $resourceClass) ||
679+
!$this->isPropertyMapped($property, $resourceClass)
680+
) {
681+
return;
682+
}
683+
676684
$parameterName = $queryNameGenerator->generateParameterName($property); // Generate a unique parameter name to avoid collisions with other filters
677685
$queryBuilder
678686
->andWhere(sprintf('REGEXP(o.%s, :%s) = 1', $property, $parameterName))

0 commit comments

Comments
 (0)