‪TYPO3CMS  9.5
Dispatcher.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 
23 {
27  protected ‪$objectManager;
28 
32  protected ‪$signalSlotDispatcher;
33 
37  protected ‪$settings = [];
38 
43  {
44  $this->signalSlotDispatcher = ‪$signalSlotDispatcher;
45  }
46 
52  public function ‪__construct(\‪TYPO3\CMS\‪Extbase\Object\ObjectManagerInterface ‪$objectManager)
53  {
54  $this->objectManager = ‪$objectManager;
55  }
56 
64  public function ‪dispatch(\‪TYPO3\CMS\‪Extbase\Mvc\‪RequestInterface $request, \‪TYPO3\CMS\‪Extbase\Mvc\‪ResponseInterface $response)
65  {
66  $dispatchLoopCount = 0;
67  while (!$request->isDispatched()) {
68  if ($dispatchLoopCount++ > 99) {
69  throw new \TYPO3\CMS\Extbase\Mvc\Exception\InfiniteLoopException('Could not ultimately dispatch the request after ' . $dispatchLoopCount . ' iterations. Most probably, a @' . \‪TYPO3\CMS\‪Extbase\Annotation\IgnoreValidation::class . ' annotation is missing on re-displaying a form with validation errors.', 1217839467);
70  }
71  $controller = $this->‪resolveController($request);
72  try {
73  $controller->processRequest($request, $response);
74  } catch (\‪TYPO3\CMS\‪Extbase\Mvc\‪Exception\StopActionException $ignoredException) {
75  }
76  }
77  $this->‪emitAfterRequestDispatchSignal($request, $response);
78  }
79 
87  {
88  $this->signalSlotDispatcher->dispatch(__CLASS__, 'afterRequestDispatch', [$request, $response]);
89  }
90 
99  protected function ‪resolveController(\‪TYPO3\CMS\‪Extbase\Mvc\‪RequestInterface $request)
100  {
101  $controllerObjectName = $request->getControllerObjectName();
102  $controller = $this->objectManager->get($controllerObjectName);
103  if (!$controller instanceof \‪TYPO3\CMS\‪Extbase\Mvc\Controller\ControllerInterface) {
104  throw new \TYPO3\CMS\Extbase\Mvc\Exception\InvalidControllerException(
105  'Invalid controller "' . $request->getControllerObjectName() . '". The controller must implement the TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ControllerInterface.',
106  1476109646
107  );
108  }
109  return $controller;
110  }
111 }
‪TYPO3\CMS\Extbase\Mvc\Exception
Definition: Exception.php:21
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:4
‪TYPO3\CMS\Extbase\Mvc\Dispatcher
Definition: Dispatcher.php:23
‪TYPO3\CMS\Extbase\Mvc\ResponseInterface
Definition: ResponseInterface.php:21
‪TYPO3
‪TYPO3\CMS\Extbase\Mvc
‪TYPO3\CMS\Extbase\Mvc\Dispatcher\resolveController
‪TYPO3 CMS Extbase Mvc Controller ControllerInterface resolveController(\TYPO3\CMS\Extbase\Mvc\RequestInterface $request)
Definition: Dispatcher.php:96
‪TYPO3\CMS\Extbase\Mvc\Dispatcher\injectSignalSlotDispatcher
‪injectSignalSlotDispatcher(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher)
Definition: Dispatcher.php:39
‪TYPO3\CMS\Extbase\Mvc\Dispatcher\$signalSlotDispatcher
‪TYPO3 CMS Extbase SignalSlot Dispatcher $signalSlotDispatcher
Definition: Dispatcher.php:30
‪TYPO3\CMS\Extbase\Mvc\Dispatcher\emitAfterRequestDispatchSignal
‪emitAfterRequestDispatchSignal(\TYPO3\CMS\Extbase\Mvc\RequestInterface $request, \TYPO3\CMS\Extbase\Mvc\ResponseInterface $response)
Definition: Dispatcher.php:83
‪TYPO3\CMS\Extbase\Mvc\Dispatcher\$objectManager
‪TYPO3 CMS Extbase Object ObjectManagerInterface $objectManager
Definition: Dispatcher.php:26
‪TYPO3\CMS\Extbase\Mvc\Dispatcher\dispatch
‪dispatch(\TYPO3\CMS\Extbase\Mvc\RequestInterface $request, \TYPO3\CMS\Extbase\Mvc\ResponseInterface $response)
Definition: Dispatcher.php:61
‪TYPO3\CMS\Extbase\Mvc\Dispatcher\__construct
‪__construct(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
Definition: Dispatcher.php:49
‪TYPO3\CMS\Extbase\Mvc\RequestInterface
Definition: RequestInterface.php:21
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:22
‪TYPO3\CMS\Extbase\Mvc\Dispatcher\$settings
‪array $settings
Definition: Dispatcher.php:34