예제 #1
0
 /**
  * visitLogicalExpression 
  * 
  * @param Expr\LogicalExpression $expr 
  * @access public
  * @return void
  */
 public function visitLogicalExpression(Expr\LogicalExpression $expr)
 {
     $exprs = array();
     foreach ($expr->getExpressions() as $innerExpr) {
         $exprs[] = $this->visit($innerExpr);
     }
     switch ($expr->getType()) {
         case Expr\LogicalExpression::TYPE_AND:
             if (1 >= count($exprs)) {
                 return implode(' ', $exprs);
             }
             return Literals::L_AND . Literals::L_COLON . Literals::L_PARENTHESIS_OPEN . implode(' ', $exprs) . Literals::L_PARENTHESIS_CLOSE;
         case Expr\LogicalExpression::TYPE_OR:
             if (1 >= count($exprs)) {
                 return implode(' ', $exprs);
             }
             return Literals::L_OR . Literals::L_COLON . Literals::L_PARENTHESIS_OPEN . implode(' ', $exprs) . Literals::L_PARENTHESIS_CLOSE;
         case Expr\LogicalExpression::TYPE_NOT:
             return Literals::L_NOT . Literals::L_COLON . Literals::L_PARENTHESIS_OPEN . implode(' ', $exprs) . Literals::L_PARENTHESIS_CLOSE;
         default:
             throw new \RuntimeException(sprintf('Unknown type of LogicalExpression operator: [%s]', (string) $expr->getType()));
     }
 }
예제 #2
0
 /**
  * visitLogicalExpression 
  * 
  * @param Expr\LogicalExpression $expr 
  * @access public
  * @return void
  */
 public function visitLogicalExpression(Expr\LogicalExpression $expr)
 {
     foreach ($expr->getExpressions() as $innerExpr) {
         $exprs[] = $this->visit($innerExpr);
     }
     $qb = $this->getQueryBuilder();
     switch ($expr->getType()) {
         case Expr\LogicalExpression::TYPE_AND:
             return new DoctrineOrmExpr\Andx($exprs);
         case Expr\LogicalExpression::TYPE_OR:
             return new DoctrineOrmExpr\Orx($exprs);
         case Expr\LogicalExpression::TYPE_NOT:
             return new DoctrineOrmExpr\Func('NOT', $exprs);
         default:
             throw new \RuntimeException(sprintf('Unknown type of LogicalExpression operator: [%s]', (string) $expr->getType()));
     }
 }