private function reloadResults() { if ($this->lastId !== null) { if ($this->filterIdOperation === null) { $this->filterIdOperation = $this->fetcher->filterByGreaterThanId($this->lastId); } else { $this->filterIdOperation->setValue($this->lastId); } } $this->results = $this->fetchable->getByFetcher($this->fetcher)->getResultSet(); if (!$this->fetcher->hasResults()) { $this->ended = true; $this->currentKey = null; } else { if ($this->fetcher->count() !== $this->fetcher->getNbByPage()) { $this->ended = true; } $this->currentKey = key($this->results); /** @var VO $vo */ $vo = current($this->results); if ($vo !== false) { $this->lastId = $vo->getId(); } } }
protected function addSimpleOperation(SimpleOperation $operation) { switch ($operation->getOperator()) { case Fetcher::TYPE_EQ: return array($operation->getColumnName() => array('$eq' => $operation->getValue())); case Fetcher::TYPE_IN: return array($operation->getColumnName() => array('$in' => $operation->getValue())); case Fetcher::TYPE_ARRAY_CONTAINS: return array($operation->getColumnName() => array('$all' => $operation->getValue())); case Fetcher::TYPE_ARRAY_LENGTH: return array($operation->getColumnName() => array('$size' => $operation->getValue())); case Fetcher::TYPE_ILIKE: return array($operation->getColumnName() => array('$regex' => preg_quote($operation->getValue()), '$options' => 'i')); case Fetcher::TYPE_LIKE: return array($operation->getColumnName() => array('$regex' => preg_quote($operation->getValue()))); default: throw new \InvalidArgumentException(sprintf('Unsupported operation : %s !', $operation->getOperator())); } }
protected function getOperationValue(SimpleOperation $operation) { switch ($operation->getOperator()) { case Fetcher::TYPE_LIKE: case Fetcher::TYPE_ILIKE: return '%' . $operation->getValue() . '%'; case Fetcher::TYPE_LOWERED_EQ: return strtolower($operation->getValue()); default: return $operation->getValue(); } }