getRequestUri(); /** Remove base url and area from path */ $areaFrontName = $areaList->getFrontName($configScope->getCurrentScope()); $pathInfo = preg_replace("#.*?/{$areaFrontName}/?#", '/', $pathInfo); /** Remove GET parameters from path */ $pathInfo = preg_replace('#\?.*#', '', $pathInfo); $this->setPathInfo($pathInfo); } /** * {@inheritdoc} * * Added CGI environment support. */ public function getHeader($header, $default = false) { $headerValue = parent::getHeader($header, $default); if ($headerValue == false) { /** Workaround for hhvm environment */ $header = 'REDIRECT_HTTP_' . strtoupper(str_replace('-', '_', $header)); if (isset($_SERVER[$header])) { $headerValue = $_SERVER[$header]; } } return $headerValue; } /** * Identify versions of resources that should be used for API configuration generation. * * @param string|null $default * @return array|string * @throws \Magento\Framework\Webapi\Exception When GET parameters are invalid */ public function getRequestedServices($default = null) { $param = $this->getParam(self::REQUEST_PARAM_SERVICES, $default); return $this->_convertRequestParamToServiceArray($param); } /** * Extract the resources query param value and return associative array of the form 'resource' => 'version' * * @param string $param eg
testModule1AllSoapAndRestV1,testModule2AllSoapNoRestV1* @return string|array
eg array ( * 'testModule1AllSoapAndRestV1', * 'testModule2AllSoapNoRestV1', * )* @throws \Magento\Framework\Webapi\Exception */ protected function _convertRequestParamToServiceArray($param) { $serviceSeparator = ','; $serviceVerPattern = "[a-zA-Z\d]*V[\d]+"; $regexp = "/^({$serviceVerPattern})([{$serviceSeparator}]{$serviceVerPattern})*\$/"; if ($param == 'all') { return $param; } //Check if the $param is of valid format if (empty($param) || !preg_match($regexp, $param)) { $message = new Phrase('Incorrect format of request URI or Requested services are missing.'); throw new \Magento\Framework\Webapi\Exception($message); } //Split the $param string to create an array of 'service' => 'version' $serviceVersionArray = explode($serviceSeparator, $param); $serviceArray = []; foreach ($serviceVersionArray as $service) { $serviceArray[] = $service; } return $serviceArray; } }