![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/app/code/Cnc/Checkout/Query/DeliveryEstimation/ |
<?php namespace Cnc\Checkout\Query\DeliveryEstimation; use Cnc\Checkout\Mapper\DeliveryEstimationDataMapper; use Cnc\Checkout\Model\ResourceModel\DeliveryEstimationModel\DeliveryEstimationCollection; use Cnc\Checkout\Model\ResourceModel\DeliveryEstimationModel\DeliveryEstimationCollectionFactory; use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\Api\SearchCriteriaInterface; use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface; use Magento\Framework\Api\SearchResultsInterface; use Magento\Framework\Api\SearchResultsInterfaceFactory; /** * Get DeliveryEstimation list by search criteria query. */ class GetListQuery { /** * @var CollectionProcessorInterface */ private $collectionProcessor; /** * @var DeliveryEstimationCollectionFactory */ private $entityCollectionFactory; /** * @var DeliveryEstimationDataMapper */ private $entityDataMapper; /** * @var SearchCriteriaBuilder */ private $searchCriteriaBuilder; /** * @var SearchResultsInterfaceFactory */ private $searchResultFactory; /** * @param CollectionProcessorInterface $collectionProcessor * @param DeliveryEstimationCollectionFactory $entityCollectionFactory * @param DeliveryEstimationDataMapper $entityDataMapper * @param SearchCriteriaBuilder $searchCriteriaBuilder * @param SearchResultsInterfaceFactory $searchResultFactory */ public function __construct( CollectionProcessorInterface $collectionProcessor, DeliveryEstimationCollectionFactory $entityCollectionFactory, DeliveryEstimationDataMapper $entityDataMapper, SearchCriteriaBuilder $searchCriteriaBuilder, SearchResultsInterfaceFactory $searchResultFactory ) { $this->collectionProcessor = $collectionProcessor; $this->entityCollectionFactory = $entityCollectionFactory; $this->entityDataMapper = $entityDataMapper; $this->searchCriteriaBuilder = $searchCriteriaBuilder; $this->searchResultFactory = $searchResultFactory; } /** * Get DeliveryEstimation list by search criteria. * * @param SearchCriteriaInterface|null $searchCriteria * * @return SearchResultsInterface */ public function execute(?SearchCriteriaInterface $searchCriteria = null): SearchResultsInterface { /** @var DeliveryEstimationCollection $collection */ $collection = $this->entityCollectionFactory->create(); if ($searchCriteria === null) { $searchCriteria = $this->searchCriteriaBuilder->create(); } else { $this->collectionProcessor->process($searchCriteria, $collection); } $entityDataObjects = $this->entityDataMapper->map($collection); /** @var SearchResultsInterface $searchResult */ $searchResult = $this->searchResultFactory->create(); $searchResult->setItems($entityDataObjects); $searchResult->setTotalCount($collection->getSize()); $searchResult->setSearchCriteria($searchCriteria); return $searchResult; } }