Doctrine\MongoDB\Query\Expr::addOr PHP Method

addOr() public method

Add one or more $or clauses to the current query.
See also: Builder::addOr()
See also: http://docs.mongodb.org/manual/reference/operator/or/
public addOr ( array | Expr $expression )
$expression array | Expr
    public function addOr($expression)
    {
        if (!isset($this->query['$or'])) {
            $this->query['$or'] = [];
        }
        $this->query['$or'] = array_merge($this->query['$or'], array_map(function ($expression) {
            return $expression instanceof Expr ? $expression->getQuery() : $expression;
        }, func_get_args()));
        return $this;
    }

Usage Example

 /**
  * {@inheritdoc}
  */
 public function addFieldFilter($field, $operator, $value, $locale = null, $scope = null, $options = [])
 {
     if (Operators::IS_EMPTY !== $operator) {
         $this->checkValue($field, $value);
         if (FieldFilterHelper::getProperty($field) === FieldFilterHelper::CODE_PROPERTY) {
             $value = $this->objectIdResolver->getIdsFromCodes('family', $value);
         }
     }
     $fieldCode = FieldFilterHelper::getCode($field);
     switch ($operator) {
         case Operators::IN_LIST:
             $expr = new Expr();
             $this->qb->addAnd($expr->field($fieldCode)->in($value));
             break;
         case Operators::NOT_IN_LIST:
             $this->qb->field($fieldCode)->notIn($value);
             break;
         case Operators::IS_EMPTY:
             $exists = new Expr();
             $equals = new Expr();
             $expr = new Expr();
             $exists->field($fieldCode)->exists(false);
             $equals->field($fieldCode)->equals(null);
             $expr->addOr($exists)->addOr($equals);
             $this->qb->addAnd($expr);
             break;
     }
     return $this;
 }
All Usage Examples Of Doctrine\MongoDB\Query\Expr::addOr