123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Framework\Search\Adapter\Mysql;
- /**
- * Response Factory
- *
- * @deprecated 102.0.0
- * @see \Magento\ElasticSearch
- */
- class ResponseFactory
- {
- /**
- * Object Manager instance
- *
- * @var \Magento\Framework\ObjectManagerInterface
- */
- protected $objectManager;
- /**
- * Document Factory
- *
- * @var DocumentFactory
- */
- protected $documentFactory;
- /**
- * Aggregation Factory
- *
- * @var AggregationFactory
- */
- protected $aggregationFactory;
- /**
- * @param \Magento\Framework\ObjectManagerInterface $objectManager
- * @param DocumentFactory $documentFactory
- * @param AggregationFactory $aggregationFactory
- */
- public function __construct(
- \Magento\Framework\ObjectManagerInterface $objectManager,
- DocumentFactory $documentFactory,
- AggregationFactory $aggregationFactory
- ) {
- $this->objectManager = $objectManager;
- $this->documentFactory = $documentFactory;
- $this->aggregationFactory = $aggregationFactory;
- }
- /**
- * Create Query Response instance
- *
- * @param mixed $rawResponse
- * @return \Magento\Framework\Search\Response\QueryResponse
- */
- public function create($rawResponse)
- {
- $documents = [];
- foreach ($rawResponse['documents'] as $rawDocument) {
- /** @var \Magento\Framework\Api\Search\Document[] $documents */
- $documents[] = $this->documentFactory->create($rawDocument);
- }
- /** @var \Magento\Framework\Search\Response\Aggregation $aggregations */
- $aggregations = $this->aggregationFactory->create($rawResponse['aggregations']);
- return $this->objectManager->create(
- \Magento\Framework\Search\Response\QueryResponse::class,
- [
- 'documents' => $documents,
- 'aggregations' => $aggregations
- ]
- );
- }
- }
|