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
7 
14 
18 class Router implements RouterInterface
19 {
23  private $actionFactory;
24 
28  private $actionList;
29 
33  private $routeConfig;
34 
40  public function __construct(
41  ActionFactory $actionFactory,
42  ActionList $actionList,
43  ConfigInterface $routeConfig
44  ) {
45  $this->actionFactory = $actionFactory;
46  $this->actionList = $actionList;
47  $this->routeConfig = $routeConfig;
48  }
49 
56  public function match(RequestInterface $request)
57  {
58  $identifier = trim($request->getPathInfo(), '/');
59  if ($identifier !== 'robots.txt') {
60  return null;
61  }
62 
63  $modules = $this->routeConfig->getModulesByFrontName('robots');
64  if (empty($modules)) {
65  return null;
66  }
67 
68  $actionClassName = $this->actionList->get($modules[0], null, 'index', 'index');
69  $actionInstance = $this->actionFactory->create($actionClassName);
70  return $actionInstance;
71  }
72 }
__construct(ActionFactory $actionFactory, ActionList $actionList, ConfigInterface $routeConfig)
Definition: Router.php:40
match(RequestInterface $request)
Definition: Router.php:56