/** * {@inheritDoc} */ public function filter($target, array $parameters, array $operators, ExecutionContext $context) { /** @var \Doctrine\DBAL\Query\QueryBuilder $target */ $this->applyFilter($target, $parameters, $operators, $context); // and return the results return IteratorTools::fromArray($target->execute()->fetchAll()); }
/** * {@inheritDoc} */ public function filter($target, array $parameters, array $operators, ExecutionContext $context) { /** @var \PommProject\Foundation\Where $whereClause */ $whereClause = $this->applyFilter($target, $parameters, $operators, $context); $method = !empty($context['method']) ? $context['method'] : 'findWhere'; $result = call_user_func([$target, $method], $whereClause); return is_array($result) ? IteratorTools::fromArray($result) : $result; }
/** * {@inheritDoc} */ public function filter($target, array $parameters, array $operators, ExecutionContext $context) { return IteratorTools::fromGenerator(function () use($target, $parameters, $operators) { foreach ($target as $row) { $targetRow = is_array($row) ? $row : new ObjectContext($row); if ($this->execute($targetRow, $operators, $parameters)) { (yield $row); } } }); }
/** * {@inheritDoc} */ public function filter($target, array $parameters, array $operators, ExecutionContext $context) { /** @var array $searchQuery */ $searchQuery = $this->execute($target, $operators, $parameters); /** @var \Elasticsearch\Client $target */ $results = $target->search(['index' => $context['index'], 'type' => $context['type'], 'body' => ['query' => $searchQuery]]); if (empty($results['hits'])) { return IteratorTools::fromArray([]); } return IteratorTools::fromArray(array_map(function ($result) { return $result['_source']; }, $results['hits']['hits'])); }
/** * {@inheritDoc} */ public function filter($target, array $parameters, array $operators, ExecutionContext $context) { /** @var \Doctrine\ORM\QueryBuilder $target */ $this->applyFilter($target, $parameters, $operators, $context); // execute the query $result = $target->getQuery()->getResult(); // and return the appropriate result type if ($result instanceof \Traversable) { return $result; } else { if (is_array($result)) { return IteratorTools::fromArray($result); } } throw new \RuntimeException(sprintf('Unhandled result type: "%s"', get_class($result))); }
/** * @inheritDoc */ public function filter($target, array $parameters, array $operators, ExecutionContext $context) { $query = $this->applyFilter($target, $parameters, $operators, $context); return IteratorTools::fromArray($query->get()); }