7 declare(strict_types=1);
18 use Magento\AsynchronousOperations\Api\Data\AsyncResponseInterfaceFactory;
38 private $inputParamsResolver;
42 private $asyncBulkPublisher;
46 private $webapiAsyncConfig;
50 private $dataObjectProcessor;
54 private $asyncResponseFactory;
58 private $processorPath;
75 WebApiAsyncConfig $webapiAsyncConfig,
77 AsyncResponseInterfaceFactory $asyncResponse,
78 $processorPath = self::PROCESSOR_PATH
81 $this->inputParamsResolver = $inputParamsResolver;
82 $this->asyncBulkPublisher = $asyncBulkPublisher;
83 $this->webapiAsyncConfig = $webapiAsyncConfig;
84 $this->dataObjectProcessor = $dataObjectProcessor;
85 $this->asyncResponseFactory = $asyncResponse;
86 $this->processorPath = $processorPath;
95 $path = preg_replace($this->processorPath,
"$1",
$path);
100 $entitiesParamsArray = $this->inputParamsResolver->resolve();
101 $topicName = $this->getTopicName(
$request);
104 $asyncResponse = $this->asyncBulkPublisher->publishMass(
109 $asyncResponse = $bulkException->
getData();
112 $responseData = $this->dataObjectProcessor->buildOutputDataArray(
114 AsyncResponseInterface::class
117 $this->response->setStatusCode(RestResponse::STATUS_CODE_202)
118 ->prepareResponse($responseData);
125 private function getTopicName(
$request)
127 $route = $this->inputParamsResolver->getRoute();
129 return $this->webapiAsyncConfig->getTopicName(
130 $route->getRoutePath(),
144 if (preg_match($this->processorPath,
$request->getPathInfo()) === 1) {
156 if (preg_match(self::BULK_PROCESSOR_PATH,
$request->getPathInfo()) === 1) {
const BULK_PROCESSOR_PATH
__construct(RestResponse $response, InputParamsResolver $inputParamsResolver, MassSchedule $asyncBulkPublisher, WebApiAsyncConfig $webapiAsyncConfig, DataObjectProcessor $dataObjectProcessor, AsyncResponseInterfaceFactory $asyncResponse, $processorPath=self::PROCESSOR_PATH)
process(\Magento\Framework\Webapi\Rest\Request $request)
isBulk(\Magento\Framework\Webapi\Rest\Request $request)
canProcess(\Magento\Framework\Webapi\Rest\Request $request)