[CLEANUP] General code cleanup
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Mvc / Web / FrontendRequestHandler.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Mvc\Web;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2010 Jochen Rau <jochen.rau@typoplanet.de>
8 * All rights reserved
9 *
10 * This class is a backport of the corresponding class of FLOW3.
11 * All credits go to the v5 team.
12 *
13 * This script is part of the TYPO3 project. The TYPO3 project is
14 * free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * The GNU General Public License can be found at
20 * http://www.gnu.org/copyleft/gpl.html.
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * A request handler which can handle web requests invoked by the frontend.
31 */
32 class FrontendRequestHandler extends \TYPO3\CMS\Extbase\Mvc\Web\AbstractRequestHandler {
33
34 /**
35 * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
36 */
37 protected $configurationManager;
38
39 /**
40 * @var \TYPO3\CMS\Extbase\Service\ExtensionService
41 */
42 protected $extensionService;
43
44 /**
45 * @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
46 * @return void
47 */
48 public function injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager) {
49 $this->configurationManager = $configurationManager;
50 }
51
52 /**
53 * @param \TYPO3\CMS\Extbase\Service\ExtensionService $extensionService
54 * @return void
55 */
56 public function injectExtensionService(\TYPO3\CMS\Extbase\Service\ExtensionService $extensionService) {
57 $this->extensionService = $extensionService;
58 }
59
60 /**
61 * Handles the web request. The response will automatically be sent to the client.
62 *
63 * @return \TYPO3\CMS\Extbase\Mvc\ResponseInterface|NULL
64 */
65 public function handleRequest() {
66 $request = $this->requestBuilder->build();
67 /** @var $requestHashService \TYPO3\CMS\Extbase\Security\Channel\RequestHashService */
68 $requestHashService = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Security\\Channel\\RequestHashService');
69 $requestHashService->verifyRequest($request);
70 if ($this->extensionService->isActionCacheable(NULL, NULL, $request->getControllerName(), $request->getControllerActionName())) {
71 $request->setIsCached(TRUE);
72 } else {
73 $contentObject = $this->configurationManager->getContentObject();
74 if ($contentObject->getUserObjectType() === \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::OBJECTTYPE_USER) {
75 $contentObject->convertToUserIntObject();
76 // tslib_cObj::convertToUserIntObject() will recreate the object, so we have to stop the request here
77 return NULL;
78 }
79 $request->setIsCached(FALSE);
80 }
81 /** @var $response \TYPO3\CMS\Extbase\Mvc\ResponseInterface */
82 $response = $this->objectManager->create('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response');
83 $this->dispatcher->dispatch($request, $response);
84 return $response;
85 }
86
87 /**
88 * This request handler can handle any web request.
89 *
90 * @return boolean If the request is a web request, TRUE otherwise FALSE
91 */
92 public function canHandleRequest() {
93 return TYPO3_MODE === 'FE';
94 }
95
96 }
97
98
99 ?>