serviceConfig = $serviceConfig; $this->pathProcessor = $pathProcessor; } /** * Apply route customization. * @param \Magento\Webapi\Controller\Rest $subject * @param RequestInterface $request * @return array * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function beforeDispatch(\Magento\Webapi\Controller\Rest $subject, RequestInterface $request) { $routeCustomizations = $this->serviceConfig->getServices()[Converter::KEY_ROUTES] ?? []; if ($routeCustomizations) { $originPath = $request->getPathInfo(); $requestMethod = $request->getMethod(); $routePath = ltrim($this->pathProcessor->process($originPath), '/'); if (array_key_exists($routePath, $routeCustomizations)) { if (isset($routeCustomizations[$routePath][$requestMethod])) { $path = ltrim($routeCustomizations[$routePath][$requestMethod], '/'); $request->setPathInfo(str_replace($routePath, $path, $originPath)); } } } return [$request]; } }