TYPO3 CMS  TYPO3_7-6
Dispatcher.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Extbase\Mvc;
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 $reflectionService;
32 
37 
41  protected $settings = [];
42 
46  public function injectReflectionService(\TYPO3\CMS\Extbase\Reflection\ReflectionService $reflectionService)
47  {
48  $this->reflectionService = $reflectionService;
49  }
50 
54  public function injectSignalSlotDispatcher(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher)
55  {
56  $this->signalSlotDispatcher = $signalSlotDispatcher;
57  }
58 
64  public function __construct(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
65  {
66  $this->objectManager = $objectManager;
67  }
68 
77  public function dispatch(\TYPO3\CMS\Extbase\Mvc\RequestInterface $request, \TYPO3\CMS\Extbase\Mvc\ResponseInterface $response)
78  {
79  $dispatchLoopCount = 0;
80  while (!$request->isDispatched()) {
81  if ($dispatchLoopCount++ > 99) {
82  throw new \TYPO3\CMS\Extbase\Mvc\Exception\InfiniteLoopException('Could not ultimately dispatch the request after ' . $dispatchLoopCount . ' iterations. Most probably, a @ignorevalidation annotation is missing on re-displaying a form with validation errors.', 1217839467);
83  }
84  $controller = $this->resolveController($request);
85  try {
86  $controller->processRequest($request, $response);
87  } catch (\TYPO3\CMS\Extbase\Mvc\Exception\StopActionException $ignoredException) {
88  }
89  }
90  $this->emitAfterRequestDispatchSignal($request, $response);
91  }
92 
99  protected function emitAfterRequestDispatchSignal(\TYPO3\CMS\Extbase\Mvc\RequestInterface $request, \TYPO3\CMS\Extbase\Mvc\ResponseInterface $response)
100  {
101  $this->signalSlotDispatcher->dispatch(__CLASS__, 'afterRequestDispatch', [$request, $response]);
102  }
103 
112  protected function resolveController(\TYPO3\CMS\Extbase\Mvc\RequestInterface $request)
113  {
114  $controllerObjectName = $request->getControllerObjectName();
115  $controller = $this->objectManager->get($controllerObjectName);
116  if (!$controller instanceof \TYPO3\CMS\Extbase\Mvc\Controller\ControllerInterface) {
117  throw new \TYPO3\CMS\Extbase\Mvc\Exception\InvalidControllerException('Invalid controller "' . $request->getControllerObjectName() . '". The controller must implement the TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ControllerInterface.', 1202921619);
118  }
119  return $controller;
120  }
121 }
__construct(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
Definition: Dispatcher.php:64
resolveController(\TYPO3\CMS\Extbase\Mvc\RequestInterface $request)
Definition: Dispatcher.php:112
emitAfterRequestDispatchSignal(\TYPO3\CMS\Extbase\Mvc\RequestInterface $request, \TYPO3\CMS\Extbase\Mvc\ResponseInterface $response)
Definition: Dispatcher.php:99
dispatch(\TYPO3\CMS\Extbase\Mvc\RequestInterface $request, \TYPO3\CMS\Extbase\Mvc\ResponseInterface $response)
Definition: Dispatcher.php:77
injectSignalSlotDispatcher(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher)
Definition: Dispatcher.php:54
injectReflectionService(\TYPO3\CMS\Extbase\Reflection\ReflectionService $reflectionService)
Definition: Dispatcher.php:46