[FEATURE] Allow ContainerViewHelper to load RequireJS modules 88/35488/6
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Mon, 15 Dec 2014 17:51:01 +0000 (18:51 +0100)
committerFrank Nägler <typo3@naegler.net>
Mon, 29 Dec 2014 08:23:58 +0000 (09:23 +0100)
Add $includeRequireJsModules to ContainerViewHelper that loads RequireJS
modules, if given.

Resolves: #63913
Releases: master
Change-Id: Ie8464963eb421eca65c0a3c750920037bcee78bc
Reviewed-on: http://review.typo3.org/35488
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Frank Nägler <typo3@naegler.net>
Tested-by: Frank Nägler <typo3@naegler.net>
typo3/sysext/core/Documentation/Changelog/master/Feature-63913-AllowRequireJsModulesForContainerViewHelper.rst [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Be/ContainerViewHelper.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-63913-AllowRequireJsModulesForContainerViewHelper.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-63913-AllowRequireJsModulesForContainerViewHelper.rst
new file mode 100644 (file)
index 0000000..da13445
--- /dev/null
@@ -0,0 +1,19 @@
+=====================================================================
+Feature: #63913 - Allow ContainerViewHelper to load RequireJS modules
+=====================================================================
+
+Description
+===========
+
+The ContainerViewHelper can load RequireJS modules via the `includeRequireJsModules` attribute. The scripts are passed
+as array.
+
+.. code-block:: html
+
+       <f:be.container pageTitle="Extension Module" loadJQuery="true"
+               includeRequireJsModules="{
+               0:'TYPO3/CMS/Extension/Module',
+               1:'TYPO3/CMS/Extension/Module2',
+               2:'TYPO3/CMS/Extension/Module3',
+               3:'TYPO3/CMS/Extension/Module4'
+       }">
index 6bcce41..2d186b8 100644 (file)
@@ -66,11 +66,12 @@ class ContainerViewHelper extends AbstractBackendViewHelper {
         * @param array $includeJsFiles List of custom JavaScript file to be loaded
         * @param array $addJsInlineLabels Custom labels to add to JavaScript inline labels
         * @param bool $includeCsh flag for including CSH
+        * @param array $includeRequireJsModules List of RequireJS modules to be loaded
         * @return string
         * @see \TYPO3\CMS\Backend\Template\DocumentTemplate
         * @see \TYPO3\CMS\Core\Page\PageRenderer
         */
-       public function render($pageTitle = '', $enableClickMenu = TRUE, $loadPrototype = TRUE, $loadScriptaculous = FALSE, $scriptaculousModule = '', $loadExtJs = FALSE, $loadExtJsTheme = TRUE, $extJsAdapter = '', $enableExtJsDebug = FALSE, $loadJQuery = FALSE, $includeCssFiles = NULL, $includeJsFiles = NULL, $addJsInlineLabels = NULL, $includeCsh = TRUE) {
+       public function render($pageTitle = '', $enableClickMenu = TRUE, $loadPrototype = TRUE, $loadScriptaculous = FALSE, $scriptaculousModule = '', $loadExtJs = FALSE, $loadExtJsTheme = TRUE, $extJsAdapter = '', $enableExtJsDebug = FALSE, $loadJQuery = FALSE, $includeCssFiles = NULL, $includeJsFiles = NULL, $addJsInlineLabels = NULL, $includeCsh = TRUE, $includeRequireJsModules = NULL) {
                $doc = $this->getDocInstance();
                $pageRenderer = $doc->getPageRenderer();
                $doc->JScode .= $doc->wrapScriptTags($doc->redirectUrls());
@@ -105,6 +106,11 @@ class ContainerViewHelper extends AbstractBackendViewHelper {
                                $pageRenderer->addJsFile($addJsFile);
                        }
                }
+               if (is_array($includeRequireJsModules) && count($includeRequireJsModules) > 0) {
+                       foreach ($includeRequireJsModules as $addRequireJsFile) {
+                               $pageRenderer->loadRequireJsModule($addRequireJsFile);
+                       }
+               }
                // Add inline language labels
                if (is_array($addJsInlineLabels) && count($addJsInlineLabels) > 0) {
                        $extensionKey = $this->controllerContext->getRequest()->getControllerExtensionKey();