[TASK] Use FQCN's when registering plugins/modules
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Mvc / Web / FrontendRequestHandler.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Mvc\Web;
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
17 /**
18 * A request handler which can handle web requests invoked by the frontend.
19 * @internal only to be used within Extbase, not part of TYPO3 Core API.
20 */
21 class FrontendRequestHandler extends AbstractRequestHandler
22 {
23 /**
24 * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
25 */
26 protected $configurationManager;
27
28 /**
29 * @var \TYPO3\CMS\Extbase\Service\ExtensionService
30 */
31 protected $extensionService;
32
33 /**
34 * @var \TYPO3\CMS\Extbase\Mvc\Web\CacheHashEnforcer
35 */
36 protected $cacheHashEnforcer;
37
38 /**
39 * @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
40 */
41 public function injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)
42 {
43 $this->configurationManager = $configurationManager;
44 }
45
46 /**
47 * @param \TYPO3\CMS\Extbase\Service\ExtensionService $extensionService
48 */
49 public function injectExtensionService(\TYPO3\CMS\Extbase\Service\ExtensionService $extensionService)
50 {
51 $this->extensionService = $extensionService;
52 }
53
54 /**
55 * @param \TYPO3\CMS\Extbase\Mvc\Web\CacheHashEnforcer $cacheHashEnforcer
56 */
57 public function injectCacheHashEnforcer(\TYPO3\CMS\Extbase\Mvc\Web\CacheHashEnforcer $cacheHashEnforcer)
58 {
59 $this->cacheHashEnforcer = $cacheHashEnforcer;
60 }
61
62 /**
63 * Handles the web request. The response will automatically be sent to the client.
64 *
65 * @return \TYPO3\CMS\Extbase\Mvc\ResponseInterface|null
66 */
67 public function handleRequest()
68 {
69 $request = $this->requestBuilder->build();
70 if ($this->extensionService->isActionCacheable(null, null, $request->getControllerObjectName(), $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 // \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::convertToUserIntObject() will recreate the object, so we have to stop the request here
77 return null;
78 }
79 $request->setIsCached(false);
80 }
81
82 if ($this->configurationManager->isFeatureEnabled('requireCHashArgumentForActionArguments')) {
83 $pluginNamespace = $this->extensionService->getPluginNamespace(
84 $request->getControllerExtensionName(),
85 $request->getPluginName()
86 );
87 $this->cacheHashEnforcer->enforceForRequest($request, $pluginNamespace);
88 }
89
90 /** @var \TYPO3\CMS\Extbase\Mvc\ResponseInterface $response */
91 $response = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\Web\Response::class);
92 $this->dispatcher->dispatch($request, $response);
93 return $response;
94 }
95
96 /**
97 * This request handler can handle any web request.
98 *
99 * @return bool If the request is a web request, TRUE otherwise FALSE
100 */
101 public function canHandleRequest()
102 {
103 return $this->environmentService->isEnvironmentInFrontendMode();
104 }
105 }