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