Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AggregationFactory.php
Go to the documentation of this file.
1 <?php
7 
15 {
21  protected $objectManager;
22 
27  {
28  $this->objectManager = $objectManager;
29  }
30 
37  public function create(array $rawAggregation)
38  {
39  $buckets = [];
40  foreach ($rawAggregation as $rawBucketName => $rawBucket) {
42  $buckets[$rawBucketName] = $this->objectManager->create(
43  \Magento\Framework\Search\Response\Bucket::class,
44  [
45  'name' => $rawBucketName,
46  'values' => $this->prepareValues((array)$rawBucket)
47  ]
48  );
49  }
50  return $this->objectManager->create(
51  \Magento\Framework\Search\Response\Aggregation::class,
52  ['buckets' => $buckets]
53  );
54  }
55 
62  private function prepareValues(array $values)
63  {
64  $valuesObjects = [];
65  foreach ($values as $name => $value) {
66  $valuesObjects[] = $this->objectManager->create(
67  \Magento\Framework\Search\Response\Aggregation\Value::class,
68  [
69  'value' => $name,
70  'metrics' => $value,
71  ]
72  );
73  }
74  return $valuesObjects;
75  }
76 }
$values
Definition: options.phtml:88
$value
Definition: gender.phtml:16
__construct(\Magento\Framework\ObjectManagerInterface $objectManager)
if(!isset($_GET['name'])) $name
Definition: log.php:14