src/Bridge/Doctrine/Orm/Filter/DateFilter.php
protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $alias, string $field, string $operator, string $value, string $nullManagement = null, $type = null)
    {
        $type = (string) $type;
        try {
            $value = false === strpos($type, '_immutable') ? new \DateTime($value) : new \DateTimeImmutable($value);
        } catch (\Exception $e) {
            // Silently ignore this filter if it can not be transformed to a \DateTime
            $this->logger->notice('Invalid filter ignored', [
                'exception' => new InvalidArgumentException(sprintf('The field "%s" has a wrong date format. Use one accepted by the \DateTime constructor', $field)),
            ]);

            return;
        }

        $valueParameter = $queryNameGenerator->generateParameterName($field);
        $operatorValue = [
            self::PARAMETER_BEFORE => '<=',
            self::PARAMETER_STRICTLY_BEFORE => '<',
            self::PARAMETER_AFTER => '>=',
            self::PARAMETER_STRICTLY_AFTER => '>',
        ];
        $baseWhere = sprintf('%s.%s %s :%s', $alias, $field, $operatorValue[$operator], $valueParameter);

        if (null === $nullManagement || self::EXCLUDE_NULL === $nullManagement) {
            $queryBuilder->andWhere($baseWhere);
        } elseif (
            (self::INCLUDE_NULL_BEFORE === $nullManagement && \in_array($operator, [self::PARAMETER_BEFORE, self::PARAMETER_STRICTLY_BEFORE], true)) ||
            (self::INCLUDE_NULL_AFTER === $nullManagement && \in_array($operator, [self::PARAMETER_AFTER, self::PARAMETER_STRICTLY_AFTER], true)) ||
            (self::INCLUDE_NULL_BEFORE_AND_AFTER === $nullManagement && \in_array($operator, [self::PARAMETER_AFTER, self::PARAMETER_STRICTLY_AFTER, self::PARAMETER_BEFORE, self::PARAMETER_STRICTLY_BEFORE], true))
        ) {
            $queryBuilder->andWhere($queryBuilder->expr()->orX(
                $baseWhere,
                $queryBuilder->expr()->isNull(sprintf('%s.%s', $alias, $field))
            ));
        } else {
            $queryBuilder->andWhere($queryBuilder->expr()->andX(
                $baseWhere,
                $queryBuilder->expr()->isNotNull(sprintf('%s.%s', $alias, $field))
            ));
        }

        $queryBuilder->setParameter($valueParameter, $value, $type);
    }
protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $alias, string $field, string $operator, string $value, string $nullManagement = null, $type = null)
    {
        $type = (string) $type;
        try {
            $value = false === strpos($type, '_immutable') ? new \DateTime($value) : new \DateTimeImmutable($value);
        } catch (\Exception $e) {
            // Silently ignore this filter if it can not be transformed to a \DateTime
            $this->logger->notice('Invalid filter ignored', [
                'exception' => new InvalidArgumentException(sprintf('The field "%s" has a wrong date format. Use one accepted by the \DateTime constructor', $field)),
            ]);

            return;
        }

        $valueParameter = $queryNameGenerator->generateParameterName($field);
        $operatorValue = [
            self::PARAMETER_BEFORE => '<=',
            self::PARAMETER_STRICTLY_BEFORE => '<',
            self::PARAMETER_AFTER => '>=',
            self::PARAMETER_STRICTLY_AFTER => '>',
        ];
        $baseWhere = sprintf('%s.%s %s :%s', $alias, $field, $operatorValue[$operator], $valueParameter);

        if (null === $nullManagement || self::EXCLUDE_NULL === $nullManagement) {
            $queryBuilder->andWhere($baseWhere);
        } elseif (
            (self::INCLUDE_NULL_BEFORE === $nullManagement && \in_array($operator, [self::PARAMETER_BEFORE, self::PARAMETER_STRICTLY_BEFORE], true)) ||
            (self::INCLUDE_NULL_AFTER === $nullManagement && \in_array($operator, [self::PARAMETER_AFTER, self::PARAMETER_STRICTLY_AFTER], true)) ||
            (self::INCLUDE_NULL_BEFORE_AND_AFTER === $nullManagement && \in_array($operator, [self::PARAMETER_AFTER, self::PARAMETER_STRICTLY_AFTER, self::PARAMETER_BEFORE, self::PARAMETER_STRICTLY_BEFORE], true))
        ) {
            $queryBuilder->andWhere($queryBuilder->expr()->orX(
                $baseWhere,
                $queryBuilder->expr()->isNull(sprintf('%s.%s', $alias, $field))
            ));
        } else {
            $queryBuilder->andWhere($queryBuilder->expr()->andX(
                $baseWhere,
                $queryBuilder->expr()->isNotNull(sprintf('%s.%s', $alias, $field))
            ));
        }

        $queryBuilder->setParameter($valueParameter, $value, $type);
    }
protected function addWhere ( QueryBuilder $ queryBuilder , QueryNameGeneratorInterface $ queryNameGenerator , string $ alias , string $ field , string $ operator , string $ value , string $ nullManagement = null , $ type = null ) { $ type = ( string ) $ type ; try { $ value = false === strpos ( $ type , '_immutable' ) ? new \ DateTime ( $ value ) : new \ DateTimeImmutable ( $ value ) ; } catch ( \ Exception $ e ) { // Silently ignore this filter if it can not be transformed to a \DateTime $ this -> logger -> notice ( 'Invalid filter ignored' , [ 'exception' => new InvalidArgumentException ( sprintf ( 'The field "%s" has a wrong date format. Use one accepted by the \DateTime constructor' , $ field ) ) , ] ) ; return ; } $ valueParameter = $ queryNameGenerator -> generateParameterName ( $ field ) ; $ operatorValue = [ self :: PARAMETER_BEFORE => '<=' , self :: PARAMETER_STRICTLY_BEFORE => '<' , self :: PARAMETER_AFTER => '>=' , self :: PARAMETER_STRICTLY_AFTER => '>' , ] ; $ baseWhere = sprintf ( '%s.%s %s :%s' , $ alias , $ field , $ operatorValue [ $ operator ] , $ valueParameter ) ; if ( null === $ nullManagement || self :: EXCLUDE_NULL === $ nullManagement ) { $ queryBuilder -> andWhere ( $ baseWhere ) ; } elseif ( ( self :: INCLUDE_NULL_BEFORE === $ nullManagement && \ in_array ( $ operator , [ self :: PARAMETER_BEFORE , self :: PARAMETER_STRICTLY_BEFORE ] , true ) ) || ( self :: INCLUDE_NULL_AFTER === $ nullManagement && \ in_array ( $ operator , [ self :: PARAMETER_AFTER , self :: PARAMETER_STRICTLY_AFTER ] , true ) ) || ( self :: INCLUDE_NULL_BEFORE_AND_AFTER === $ nullManagement && \ in_array ( $ operator , [ self :: PARAMETER_AFTER , self :: PARAMETER_STRICTLY_AFTER , self :: PARAMETER_BEFORE , self :: PARAMETER_STRICTLY_BEFORE ] , true ) ) ) { $ queryBuilder -> andWhere ( $ queryBuilder -> expr ( ) -> orX ( $ baseWhere , $ queryBuilder -> expr ( ) -> isNull ( sprintf ( '%s.%s' , $ alias , $ field ) ) ) ) ; } else { $ queryBuilder -> andWhere ( $ queryBuilder -> expr ( ) -> andX ( $ baseWhere , $ queryBuilder -> expr ( ) -> isNotNull ( sprintf ( '%s.%s' , $ alias , $ field ) ) ) ) ; } $ queryBuilder -> setParameter ( $ valueParameter , $ value , $ type ) ; }
Adds the where clause according to the chosen null management.

@param string|DBALType $type
Adds the where clause according to the chosen null management .