Пример #1
0
 /**
  * Check if current request is schema request.
  *
  * @return bool
  */
 protected function isSchemaRequest()
 {
     return $this->_request->getPathInfo() === self::SCHEMA_PATH;
 }
Пример #2
0
 /**
  * Generate the list of available REST routes. Current HTTP method is taken into account.
  *
  * @param \Magento\Framework\Webapi\Rest\Request $request
  * @return Route[] matched routes
  * @throws \Magento\Framework\Webapi\Exception
  */
 public function getRestRoutes(\Magento\Framework\Webapi\Rest\Request $request)
 {
     $requestHttpMethod = $request->getHttpMethod();
     $servicesRoutes = $this->_config->getServices()[Converter::KEY_ROUTES];
     $routes = [];
     // Return the route on exact match
     if (isset($servicesRoutes[$request->getPathInfo()][$requestHttpMethod])) {
         $methodInfo = $servicesRoutes[$request->getPathInfo()][$requestHttpMethod];
         $routes[] = $this->_createRoute([self::KEY_ROUTE_PATH => $request->getPathInfo(), self::KEY_CLASS => $methodInfo[Converter::KEY_SERVICE][Converter::KEY_SERVICE_CLASS], self::KEY_METHOD => $methodInfo[Converter::KEY_SERVICE][Converter::KEY_SERVICE_METHOD], self::KEY_IS_SECURE => $methodInfo[Converter::KEY_SECURE], self::KEY_ACL_RESOURCES => array_keys($methodInfo[Converter::KEY_ACL_RESOURCES]), self::KEY_PARAMETERS => $methodInfo[Converter::KEY_DATA_PARAMETERS]]);
         return $routes;
     }
     $serviceBaseUrl = $this->_getServiceBaseUrl($request);
     ksort($servicesRoutes, SORT_STRING);
     foreach ($servicesRoutes as $url => $httpMethods) {
         // skip if baseurl is not null and does not match
         if (!$serviceBaseUrl || strpos(trim($url, '/'), trim($serviceBaseUrl, '/')) !== 0) {
             // base url does not match, just skip this service
             continue;
         }
         foreach ($httpMethods as $httpMethod => $methodInfo) {
             if (strtoupper($httpMethod) == strtoupper($requestHttpMethod)) {
                 $aclResources = array_keys($methodInfo[Converter::KEY_ACL_RESOURCES]);
                 $routes[] = $this->_createRoute([self::KEY_ROUTE_PATH => $url, self::KEY_CLASS => $methodInfo[Converter::KEY_SERVICE][Converter::KEY_SERVICE_CLASS], self::KEY_METHOD => $methodInfo[Converter::KEY_SERVICE][Converter::KEY_SERVICE_METHOD], self::KEY_IS_SECURE => $methodInfo[Converter::KEY_SECURE], self::KEY_ACL_RESOURCES => $aclResources, self::KEY_PARAMETERS => $methodInfo[Converter::KEY_DATA_PARAMETERS]]);
             }
         }
     }
     return $routes;
 }