![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-robots/Controller/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Robots\Controller; use Magento\Framework\App\ActionFactory; use Magento\Framework\App\ActionInterface; use Magento\Framework\App\RequestInterface; use Magento\Framework\App\Route\ConfigInterface; use Magento\Framework\App\Router\ActionList; use Magento\Framework\App\RouterInterface; /** * Matches application action in case when robots.txt file was requested */ class Router implements RouterInterface { /** * @var ActionFactory */ private $actionFactory; /** * @var ActionList */ private $actionList; /** * @var ConfigInterface */ private $routeConfig; /** * @param ActionFactory $actionFactory * @param ActionList $actionList * @param ConfigInterface $routeConfig */ public function __construct( ActionFactory $actionFactory, ActionList $actionList, ConfigInterface $routeConfig ) { $this->actionFactory = $actionFactory; $this->actionList = $actionList; $this->routeConfig = $routeConfig; } /** * Checks if robots.txt file was requested and returns instance of matched application action class * * @param RequestInterface $request * @return ActionInterface|null */ public function match(RequestInterface $request) { $identifier = trim($request->getPathInfo(), '/'); if ($identifier !== 'robots.txt') { return null; } $modules = $this->routeConfig->getModulesByFrontName('robots'); if (empty($modules)) { return null; } $actionClassName = $this->actionList->get($modules[0], null, 'index', 'index'); $actionInstance = $this->actionFactory->create($actionClassName); return $actionInstance; } }