ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\NumericFilter::filterProperty PHP Method

filterProperty() protected method

protected filterProperty ( string $property, $value, Doctrine\ORM\QueryBuilder $queryBuilder, ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, string $operationName = null )
$property string
$queryBuilder Doctrine\ORM\QueryBuilder
$queryNameGenerator ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface
$resourceClass string
$operationName string
    protected function filterProperty(string $property, $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, string $operationName = null)
    {
        if (!$this->isPropertyEnabled($property) || !$this->isPropertyMapped($property, $resourceClass) || !$this->isNumericField($property, $resourceClass)) {
            return;
        }
        if (!is_numeric($value)) {
            $this->logger->notice('Invalid filter ignored', ['exception' => new InvalidArgumentException(sprintf('Invalid numeric value for "%s" property', $property))]);
            return;
        }
        $alias = 'o';
        $field = $property;
        if ($this->isPropertyNested($property)) {
            list($alias, $field) = $this->addJoinsForNestedProperty($property, $alias, $queryBuilder, $queryNameGenerator);
        }
        $valueParameter = $queryNameGenerator->generateParameterName($field);
        $queryBuilder->andWhere(sprintf('%s.%s = :%s', $alias, $field, $valueParameter))->setParameter($valueParameter, $value);
    }