‪TYPO3CMS  9.5
RequestHandlerResolver.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
22 {
26  protected ‪$objectManager;
27 
31  protected ‪$configurationManager;
32 
36  public function ‪injectObjectManager(\‪TYPO3\CMS\‪Extbase\Object\ObjectManagerInterface ‪$objectManager)
37  {
38  $this->objectManager = ‪$objectManager;
39  }
40 
44  public function ‪injectConfigurationManager(\‪TYPO3\CMS\‪Extbase\Configuration\ConfigurationManagerInterface ‪$configurationManager)
45  {
46  $this->configurationManager = ‪$configurationManager;
47  }
48 
56  public function ‪resolveRequestHandler()
57  {
58  $availableRequestHandlerClassNames = $this->‪getRegisteredRequestHandlerClassNames();
59  $suitableRequestHandlers = [];
60  foreach ($availableRequestHandlerClassNames as $requestHandlerClassName) {
61  $requestHandler = $this->objectManager->get($requestHandlerClassName);
62  if ($requestHandler->canHandleRequest()) {
63  $priority = $requestHandler->getPriority();
64  if (isset($suitableRequestHandlers[$priority])) {
65  throw new \TYPO3\CMS\Extbase\Mvc\Exception('More than one request handler with the same priority can handle the request, but only one handler may be active at a time!', 1176475350);
66  }
67  $suitableRequestHandlers[$priority] = $requestHandler;
68  }
69  }
70  if (empty($suitableRequestHandlers)) {
71  throw new \TYPO3\CMS\Extbase\Mvc\Exception('No suitable request handler found.', 1205414233);
72  }
73  ksort($suitableRequestHandlers);
74  return array_pop($suitableRequestHandlers);
75  }
76 
83  {
84  $settings = $this->configurationManager->getConfiguration(\‪TYPO3\CMS\‪Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
85  return is_array($settings['mvc']['requestHandlers']) ? $settings['mvc']['requestHandlers'] : [];
86  }
87 }
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:4
‪TYPO3\CMS\Extbase\Mvc\RequestHandlerResolver\getRegisteredRequestHandlerClassNames
‪array getRegisteredRequestHandlerClassNames()
Definition: RequestHandlerResolver.php:80
‪TYPO3
‪TYPO3\CMS\Extbase\Mvc\RequestHandlerResolver\$configurationManager
‪TYPO3 CMS Extbase Configuration ConfigurationManagerInterface $configurationManager
Definition: RequestHandlerResolver.php:29
‪TYPO3\CMS\Extbase\Mvc
‪TYPO3\CMS\Extbase\Mvc\RequestHandlerResolver\resolveRequestHandler
‪TYPO3 CMS Extbase Mvc RequestHandlerInterface resolveRequestHandler()
Definition: RequestHandlerResolver.php:54
‪TYPO3\CMS\Extbase\Mvc\RequestHandlerResolver\injectConfigurationManager
‪injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)
Definition: RequestHandlerResolver.php:42
‪TYPO3\CMS\Extbase\Mvc\RequestHandlerResolver\$objectManager
‪TYPO3 CMS Extbase Object ObjectManagerInterface $objectManager
Definition: RequestHandlerResolver.php:25
‪TYPO3\CMS\Extbase\Mvc\RequestHandlerResolver
Definition: RequestHandlerResolver.php:22
‪TYPO3\CMS\Extbase\Mvc\RequestHandlerResolver\injectObjectManager
‪injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
Definition: RequestHandlerResolver.php:34