[BUGFIX] Remove competing injects from WidgetRequestHandler
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / Core / Widget / WidgetRequestHandler.php
1 <?php
2 namespace TYPO3\CMS\Fluid\Core\Widget;
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 * Widget request handler, which handles the request if
19 * f3-fluid-widget-id is found.
20 *
21 * This Request Handler gets the WidgetRequestBuilder injected.
22 */
23 class WidgetRequestHandler extends \TYPO3\CMS\Extbase\Mvc\Web\AbstractRequestHandler
24 {
25 /**
26 * @var \TYPO3\CMS\Fluid\Core\Widget\AjaxWidgetContextHolder
27 */
28 protected $ajaxWidgetContextHolder;
29
30 /**
31 * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
32 */
33 protected $configurationManager;
34
35 /**
36 * @var \TYPO3\CMS\Fluid\Core\Widget\WidgetRequestBuilder
37 */
38 protected $requestBuilder;
39
40 /**
41 * @param \TYPO3\CMS\Fluid\Core\Widget\AjaxWidgetContextHolder $ajaxWidgetContextHolder
42 */
43 public function injectAjaxWidgetContextHolder(\TYPO3\CMS\Fluid\Core\Widget\AjaxWidgetContextHolder $ajaxWidgetContextHolder)
44 {
45 $this->ajaxWidgetContextHolder = $ajaxWidgetContextHolder;
46 }
47
48 /**
49 * @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
50 */
51 public function injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)
52 {
53 $this->configurationManager = $configurationManager;
54 }
55
56 /**
57 * @param \TYPO3\CMS\Extbase\Mvc\Web\RequestBuilder $requestBuilder
58 */
59 public function injectRequestBuilder(\TYPO3\CMS\Extbase\Mvc\Web\RequestBuilder $requestBuilder)
60 {
61 // This method intentionally left blank
62 }
63
64 /**
65 * @param \TYPO3\CMS\Fluid\Core\Widget\WidgetRequestBuilder $requestBuilder
66 */
67 public function injectWidgetRequestBuilder(\TYPO3\CMS\Fluid\Core\Widget\WidgetRequestBuilder $requestBuilder)
68 {
69 $this->requestBuilder = $requestBuilder;
70 }
71
72 /**
73 * Handles the web request. The response will automatically be sent to the client.
74 *
75 * @return \TYPO3\CMS\Extbase\Mvc\Web\Response
76 */
77 public function handleRequest()
78 {
79 $request = $this->requestBuilder->build();
80 $response = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\Web\Response::class);
81 $this->dispatcher->dispatch($request, $response);
82 return $response;
83 }
84
85 /**
86 * @return bool TRUE if it is an AJAX widget request
87 */
88 public function canHandleRequest()
89 {
90 $rawGetArguments = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET();
91 return isset($rawGetArguments['fluid-widget-id']);
92 }
93
94 /**
95 * This request handler has a higher priority than the default request handler.
96 *
97 * @return int
98 */
99 public function getPriority()
100 {
101 return 200;
102 }
103 }