‪TYPO3CMS  9.5
WidgetRequestBuilder.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
21 
26 {
31 
36  {
37  $this->ajaxWidgetContextHolder = ‪$ajaxWidgetContextHolder;
38  }
39 
45  public function ‪build(): ‪RequestInterface
46  {
47  $request = $this->objectManager->get(WidgetRequest::class);
48  $request->setRequestUri(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
49  $request->setBaseUri(GeneralUtility::getIndpEnv('TYPO3_SITE_URL'));
50  $request->setMethod($_SERVER['REQUEST_METHOD'] ?? null);
51  if (strtolower($_SERVER['REQUEST_METHOD']) === 'post') {
52  $request->‪setArguments(GeneralUtility::_POST());
53  } else {
54  $request->setArguments(GeneralUtility::_GET());
55  }
56  $rawGetArguments = GeneralUtility::_GET();
57  if (isset($rawGetArguments['action'])) {
58  $request->setControllerActionName($rawGetArguments['action']);
59  }
60  if (!isset($rawGetArguments['fluid-widget-id'])) {
61  // Low level test, WidgetRequestHandler returns false in canHandleRequest () if this is not set
62  throw new \InvalidArgumentException(
63  'No Fluid Widget ID was given.',
64  1521190675
65  );
66  }
67  $widgetContext = $this->ajaxWidgetContextHolder->get($rawGetArguments['fluid-widget-id']);
68  $request->setWidgetContext($widgetContext);
69  return $request;
70  }
71 }
‪TYPO3\CMS\Fluid\Core\Widget
Definition: AbstractWidgetController.php:2
‪TYPO3\CMS\Fluid\Core\Widget\WidgetRequestBuilder\injectAjaxWidgetContextHolder
‪injectAjaxWidgetContextHolder(AjaxWidgetContextHolder $ajaxWidgetContextHolder)
Definition: WidgetRequestBuilder.php:34
‪TYPO3\CMS\Fluid\Core\Widget\WidgetRequestBuilder
Definition: WidgetRequestBuilder.php:26
‪TYPO3\CMS\Extbase\Mvc\RequestInterface\setArguments
‪setArguments(array $arguments)
‪TYPO3\CMS\Fluid\Core\Widget\WidgetRequestBuilder\build
‪RequestInterface build()
Definition: WidgetRequestBuilder.php:44
‪TYPO3\CMS\Extbase\Mvc\RequestInterface
Definition: RequestInterface.php:21
‪TYPO3\CMS\Fluid\Core\Widget\AjaxWidgetContextHolder
Definition: AjaxWidgetContextHolder.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Fluid\Core\Widget\WidgetRequestBuilder\$ajaxWidgetContextHolder
‪AjaxWidgetContextHolder $ajaxWidgetContextHolder
Definition: WidgetRequestBuilder.php:29
‪TYPO3\CMS\Extbase\Mvc\Web\RequestBuilder
Definition: RequestBuilder.php:29