protected function applyFilters(QueryBuilder $qb, array $filters)
    {
        $definition = $this->objectDefinition;
        foreach ($filters as $field => $value) {
            if (!$definition->hasField($field) || !$prop = $definition->getField($field)->getOriginName()) {
                continue;
            }

            $entityField = sprintf('%s.%s', $this->queryAlias, $prop);

            switch (gettype($value)) {
                case 'string':
                    $qb->andWhere($qb->expr()->eq($entityField, $qb->expr()->literal($value)));
                    break;
                case 'integer':
                case 'double':
                    $qb->andWhere($qb->expr()->eq($entityField, $value));
                    break;
                case 'boolean':
                    $qb->andWhere($qb->expr()->eq($entityField, (int) $value));
                    break;
                case 'array':
                    if (empty($value)) {
                        $qb->andWhere($qb->expr()->isNull($entityField));
                    } else {
                        $qb->andWhere($qb->expr()->in($entityField, $value));
                    }
                    break;
                case 'NULL':
                    $qb->andWhere($qb->expr()->isNull($entityField));
                    break;
            }
        }
    }
protected function applyFilters(QueryBuilder $qb, array $filters)
    {
        $definition = $this->objectDefinition;
        foreach ($filters as $field => $value) {
            if (!$definition->hasField($field) || !$prop = $definition->getField($field)->getOriginName()) {
                continue;
            }

            $entityField = sprintf('%s.%s', $this->queryAlias, $prop);

            switch (gettype($value)) {
                case 'string':
                    $qb->andWhere($qb->expr()->eq($entityField, $qb->expr()->literal($value)));
                    break;
                case 'integer':
                case 'double':
                    $qb->andWhere($qb->expr()->eq($entityField, $value));
                    break;
                case 'boolean':
                    $qb->andWhere($qb->expr()->eq($entityField, (int) $value));
                    break;
                case 'array':
                    if (empty($value)) {
                        $qb->andWhere($qb->expr()->isNull($entityField));
                    } else {
                        $qb->andWhere($qb->expr()->in($entityField, $value));
                    }
                    break;
                case 'NULL':
                    $qb->andWhere($qb->expr()->isNull($entityField));
                    break;
            }
        }
    }
protected function applyFilters ( QueryBuilder $ qb , array $ filters ) { $ definition = $ this -> objectDefinition ; foreach ( $ filters as $ field => $ value ) { if ( ! $ definition -> hasField ( $ field ) || ! $ prop = $ definition -> getField ( $ field ) -> getOriginName ( ) ) { continue ; } $ entityField = sprintf ( '%s.%s' , $ this -> queryAlias , $ prop ) ; switch ( gettype ( $ value ) ) { case 'string' : $ qb -> andWhere ( $ qb -> expr ( ) -> eq ( $ entityField , $ qb -> expr ( ) -> literal ( $ value ) ) ) ; break ; case 'integer' : case 'double' : $ qb -> andWhere ( $ qb -> expr ( ) -> eq ( $ entityField , $ value ) ) ; break ; case 'boolean' : $ qb -> andWhere ( $ qb -> expr ( ) -> eq ( $ entityField , ( int ) $ value ) ) ; break ; case 'array' : if ( empty ( $ value ) ) { $ qb -> andWhere ( $ qb -> expr ( ) -> isNull ( $ entityField ) ) ; } else { $ qb -> andWhere ( $ qb -> expr ( ) -> in ( $ entityField , $ value ) ) ; } break ; case 'NULL' : $ qb -> andWhere ( $ qb -> expr ( ) -> isNull ( $ entityField ) ) ; break ; } } }
Apply advanced filters

@deprecated since v1.1, `applyWhere` should be used instead
Apply advanced filters