public function testAddOperator() { $this->subject = new Filter(); $this->subject->addOperator($this->abstractOperatorMock); $operators = $this->subject->getOperators(); $this->assertInstanceOf('ABK\\QueryBundle\\Filter\\Operators\\OperatorInterface', $operators[0]); }
protected function addFilter($filterId, $asQuery = false) { $filter = new Filter(); if ($filterId === null) { $filterId = uniqid(); } $filter->setName($filterId); if ($this->currentFilter === null) { $this->currentFilter = $filter; if ($asQuery) { $this->query = $filter; } else { $this->filters->add($filter); } } else { $nestedFilter = new NestedFilter($filter); if ($this->currentFilter instanceof Filter) { $this->currentFilter->addOperator($nestedFilter); } elseif ($this->currentFilter instanceof NestedFilter) { $this->currentFilter->getFilter()->addOperator($nestedFilter); } $this->currentFilter = $nestedFilter; } }