[FEATURE] - Let FLUIDTEMPLATE mimic an actual extbase web request 14/50814/2
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Thu, 1 Dec 2016 02:59:11 +0000 (03:59 +0100)
committerJan Helke <typo3@helke.de>
Thu, 1 Dec 2016 10:37:44 +0000 (11:37 +0100)
Adds the possibility to let the FLUIDTEMPLATE content element mimic an
actual extbase web request.
This makes it possible to access submitted data like in extbase with
...->controllerContext->getRequest()->getArguments()

Resolves: #78842
Releases: master
Change-Id: I27e34e11ae9d5526ee694825cb74b6fcc6e42061
Reviewed-on: https://review.typo3.org/50814
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Gleb Levitin <gleb.levitin@dkd.de>
Tested-by: Gleb Levitin <gleb.levitin@dkd.de>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
typo3/sysext/core/Documentation/Changelog/master/Feature-78842-LetFluidtemplateMimicAnActualExtbaseWebRequest.rst [new file with mode: 0644]
typo3/sysext/frontend/Classes/ContentObject/FluidTemplateContentObject.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-78842-LetFluidtemplateMimicAnActualExtbaseWebRequest.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-78842-LetFluidtemplateMimicAnActualExtbaseWebRequest.rst
new file mode 100644 (file)
index 0000000..d58fb6d
--- /dev/null
@@ -0,0 +1,40 @@
+.. include:: ../../Includes.txt
+
+=======================================================================
+Feature: #78842 - Let FLUIDTEMPLATE mimic an actual extbase web request
+=======================================================================
+
+See :issue:`78842`
+
+Description
+===========
+
+Adds the possibility to let the FLUIDTEMPLATE content element mimic an
+actual extbase web request.
+This makes it possible to access submitted data like in extbase with
+...->controllerContext->getRequest()->getArguments()
+
+
+Impact
+======
+
+Data which was submitted through a FLUIDTEMPLATE content element are now
+available within
+... $view->getRenderingContext()
+        ->getControllerContext()
+        ->getRequest()
+        ->getArguments()
+
+
+Affected Installations
+======================
+
+Any installation which use the FLUIDTEMPLATE content element which are
+initialized with the following settings:
+
+extbase.pluginName
+extbase.controllerExtensionName
+extbase.controllerName
+extbase.controllerActionName
+
+.. index:: Frontend
index fa1f2cc..1562137 100644 (file)
@@ -16,6 +16,9 @@ namespace TYPO3\CMS\Frontend\ContentObject;
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\StringUtility;
+use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
+use TYPO3\CMS\Extbase\Mvc\Web\RequestBuilder;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Extbase\Service\TypoScriptService;
 use TYPO3\CMS\Fluid\View\StandaloneView;
 
@@ -240,6 +243,32 @@ class FluidTemplateContentObject extends AbstractContentObject
         if ($requestControllerActionName) {
             $this->view->getRequest()->setControllerActionName($requestControllerActionName);
         }
+
+        if (
+            $requestPluginName
+            && $requestControllerExtensionName
+            && $requestControllerName
+            && $requestControllerActionName
+        ) {
+            $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManager::class);
+            $configurationManager->setConfiguration([
+                'extensionName' => $requestControllerExtensionName,
+                'pluginName' => $requestPluginName,
+            ]);
+
+            if (!isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$requestControllerExtensionName]['plugins'][$requestPluginName]['controllers'])) {
+                $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$requestControllerExtensionName]['plugins'][$requestPluginName]['controllers'] = [
+                    $requestControllerName => [
+                        'actions' => [
+                            $requestControllerActionName,
+                        ],
+                    ],
+                ];
+            }
+
+            $requestBuilder = GeneralUtility::makeInstance(ObjectManager::class)->get(RequestBuilder::class);
+            $this->view->getRenderingContext()->getControllerContext()->setRequest($requestBuilder->build());
+        }
     }
 
     /**