Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Router.php
Go to the documentation of this file.
1 <?php
9 
10 use \Magento\Framework\Webapi\Rest\Request;
11 
12 class Router
13 {
17  protected $_routes = [];
18 
22  protected $_apiConfig;
23 
29  public function __construct(\Magento\Webapi\Model\Rest\Config $apiConfig)
30  {
31  $this->_apiConfig = $apiConfig;
32  }
33 
42  public function match(Request $request)
43  {
45  $routes = $this->_apiConfig->getRestRoutes($request);
46  $matched = [];
47  foreach ($routes as $route) {
48  $params = $route->match($request);
49  if ($params !== false) {
50  $request->setParams($params);
51  $matched[] = $route;
52  }
53  }
54  if (!empty($matched)) {
55  return array_pop($matched);
56  }
57  throw new \Magento\Framework\Webapi\Exception(
58  __('Request does not match any route.'),
59  0,
60  \Magento\Framework\Webapi\Exception::HTTP_NOT_FOUND
61  );
62  }
63 }
__()
Definition: __.php:13
__construct(\Magento\Webapi\Model\Rest\Config $apiConfig)
Definition: Router.php:29
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18