Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
Router Class Reference
Inheritance diagram for Router:
RouterInterface

Public Member Functions

 __construct (ActionFactory $actionFactory, ActionList $actionList, ConfigInterface $routeConfig)
 
 match (RequestInterface $request)
 

Detailed Description

Matches application action in case when robots.txt file was requested

Definition at line 18 of file Router.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( ActionFactory  $actionFactory,
ActionList  $actionList,
ConfigInterface  $routeConfig 
)
Parameters
ActionFactory$actionFactory
ActionList$actionList
ConfigInterface$routeConfig

Definition at line 40 of file Router.php.

44  {
45  $this->actionFactory = $actionFactory;
46  $this->actionList = $actionList;
47  $this->routeConfig = $routeConfig;
48  }

Member Function Documentation

◆ match()

match ( RequestInterface  $request)

Checks if robots.txt file was requested and returns instance of matched application action class

Parameters
RequestInterface$request
Returns
ActionInterface|null

Implements RouterInterface.

Definition at line 56 of file Router.php.

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  }

The documentation for this class was generated from the following file: