request = $request; $this->paramsOverrider = $paramsOverrider; $this->serviceInputProcessor = $inputProcessor; $this->router = $router; $this->requestValidator = $requestValidator; $this->inputParamsResolver = $inputParamsResolver; $this->isBulk = $isBulk; } /** * Process and resolve input parameters * * Return array with validated input params * or throw \Exception if at least one request entity params is not valid * * @return array * @throws \Magento\Framework\Exception\InputException if no value is provided for required parameters * @throws \Magento\Framework\Webapi\Exception * @throws \Magento\Framework\Exception\AuthorizationException */ public function resolve() { if ($this->isBulk === false) { return [$this->inputParamsResolver->resolve()]; } $this->requestValidator->validate(); $webapiResolvedParams = []; $inputData = $this->request->getRequestData(); $httpMethod = $this->request->getHttpMethod(); if ($httpMethod == \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_DELETE) { $requestBodyParams = $this->request->getBodyParams(); $inputData = array_merge($requestBodyParams, $inputData); } foreach ($inputData as $key => $singleEntityParams) { $webapiResolvedParams[$key] = $this->resolveBulkItemParams($singleEntityParams); } return $webapiResolvedParams; } /** * Returns route. * * @return \Magento\Webapi\Controller\Rest\Router\Route */ public function getRoute() { return $this->inputParamsResolver->getRoute(); } /** * Resolve parameters for service * * Convert the input array from key-value format to a list of parameters * suitable for the specified class / method. * * Instead of \Magento\Webapi\Controller\Rest\InputParamsResolver * we don't need to merge body params with url params and use only body params * * @param array $inputData data to send to method in key-value format * @return array list of parameters that can be used to call the service method * @throws \Magento\Framework\Exception\InputException if no value is provided for required parameters * @throws \Magento\Framework\Webapi\Exception */ private function resolveBulkItemParams($inputData) { $route = $this->getRoute(); $serviceMethodName = $route->getServiceMethod(); $serviceClassName = $route->getServiceClass(); $inputParams = $this->serviceInputProcessor->process($serviceClassName, $serviceMethodName, $inputData); return $inputParams; } }