Example #1
0
 /**
  * {@inheritdoc}
  */
 public function restrict($expression, $condition = DataSourceInterface::CONDITION_AND)
 {
     switch ($condition) {
         case DataSourceInterface::CONDITION_AND:
             $parentNode = $this->queryBuilder->andWhere();
             break;
         case DataSourceInterface::CONDITION_OR:
             $parentNode = $this->queryBuilder->orWhere();
             break;
         default:
             throw new \RuntimeException(sprintf('Unknown restrict condition "%s"', $condition));
     }
     $visitor = new ExpressionVisitor($this->queryBuilder);
     $visitor->dispatch($expression, $parentNode);
 }
Example #2
0
 function it_should_restrict_with_or_condition(Comparison $comparison, Value $value, QueryBuilder $queryBuilder, ConstraintOrx $constraint, ConstraintComparison $comparisonConstraint)
 {
     $queryBuilder->orWhere()->willReturn($constraint);
     $value->getValue()->willReturn('value');
     $comparison->getValue()->willReturn($value);
     $comparison->getField()->willReturn('foo');
     $comparison->getOperator()->willReturn('=');
     $constraint->eq()->willReturn($comparisonConstraint);
     $comparisonConstraint->field('o.foo')->willReturn($comparisonConstraint);
     $comparisonConstraint->literal('value')->shouldBeCalled()->willReturn($comparisonConstraint);
     $comparisonConstraint->end()->shouldBeCalled();
     $this->restrict($comparison, DataSourceInterface::CONDITION_OR);
 }