20 private $algorithmRepository;
25 private $entityStorageFactory;
33 $this->algorithmRepository = $algorithmRepository;
34 $this->entityStorageFactory = $entityStorageFactory;
40 public function build(
41 RequestBucketInterface $bucket,
47 $algorithm = $this->algorithmRepository->get($bucket->getMethod(), [
'dataProvider' => $dataProvider]);
48 $data = $algorithm->getItems($bucket, $dimensions, $this->getEntityStorage($queryResult));
49 $resultData = $this->prepareData(
$data);
60 private function getEntityStorage(array $queryResult)
63 foreach ($queryResult[
'hits'][
'hits'] as $document) {
64 $ids[] = $document[
'_id'];
67 return $this->entityStorageFactory->create($ids);
76 private function prepareData(
$data)
80 $from = is_numeric(
$value[
'from']) ?
$value[
'from'] :
'*';
84 $rangeName =
"{$from}_{$to}";
85 $resultData[$rangeName] = array_merge([
'value' => $rangeName],
$value);
__construct(Repository $algorithmRepository, EntityStorageFactory $entityStorageFactory)
build(RequestBucketInterface $bucket, array $dimensions, array $queryResult, DataProviderInterface $dataProvider)