TYPO3 CMS  TYPO3_8-7
WidgetRequestBuilder.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 
18 
23 {
28 
33  {
34  $this->ajaxWidgetContextHolder = $ajaxWidgetContextHolder;
35  }
36 
42  public function build()
43  {
44  $request = $this->objectManager->get(\TYPO3\CMS\Fluid\Core\Widget\WidgetRequest::class);
45  $request->setRequestUri(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
46  $request->setBaseUri(GeneralUtility::getIndpEnv('TYPO3_SITE_URL'));
47  $request->setMethod(isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null);
48  if (strtolower($_SERVER['REQUEST_METHOD']) === 'post') {
49  $request->setArguments(GeneralUtility::_POST());
50  } else {
51  $request->setArguments(GeneralUtility::_GET());
52  }
53  $rawGetArguments = GeneralUtility::_GET();
54  if (isset($rawGetArguments['action'])) {
55  $request->setControllerActionName($rawGetArguments['action']);
56  }
57  $widgetContext = $this->ajaxWidgetContextHolder->get($rawGetArguments['fluid-widget-id']);
58  $request->setWidgetContext($widgetContext);
59  return $request;
60  }
61 }
injectAjaxWidgetContextHolder(\TYPO3\CMS\Fluid\Core\Widget\AjaxWidgetContextHolder $ajaxWidgetContextHolder)