Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ResponseFactory.php
Go to the documentation of this file.
1 <?php
7 
9 
16 {
23  protected $objectManager;
24 
31  protected $documentFactory;
32 
40 
46  public function __construct(
50  ) {
51  $this->objectManager = $objectManager;
52  $this->documentFactory = $documentFactory;
53  $this->aggregationFactory = $aggregationFactory;
54  }
55 
63  public function create($response)
64  {
65  $documents = [];
66  foreach ($response['documents'] as $rawDocument) {
68  $documents[] = $this->documentFactory->create(
69  $rawDocument
70  );
71  }
73  $aggregations = $this->aggregationFactory->create($response['aggregations']);
74  return $this->objectManager->create(
75  \Magento\Framework\Search\Response\QueryResponse::class,
76  [
77  'documents' => $documents,
78  'aggregations' => $aggregations,
79  ]
80  );
81  }
82 }
$response
Definition: 404.php:11
__construct(ObjectManagerInterface $objectManager, DocumentFactory $documentFactory, AggregationFactory $aggregationFactory)