‪TYPO3CMS  11.5
ContainerViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use TYPO3\CMS\Core\Page\PageRenderer;
21 
54 {
58  protected ‪$escapeOutput = false;
59 
65  public function ‪initializeArguments()
66  {
67  parent::initializeArguments();
68  $this->registerArgument('pageTitle', 'string', 'Title tag of the module. Not required by default, as BE modules are shown in a frame', false, '');
69  $this->registerArgument('includeCssFiles', 'array', 'List of custom CSS file to be loaded');
70  $this->registerArgument('includeJsFiles', 'array', 'List of custom JavaScript file to be loaded');
71  $this->registerArgument('addJsInlineLabels', 'array', 'Custom labels to add to JavaScript inline labels');
72  $this->registerArgument('includeRequireJsModules', 'array', 'List of RequireJS modules to be loaded');
73  $this->registerArgument('enableDocHeader', 'bool', 'Add an empty doc header', false);
74  }
75 
82  public function ‪render()
83  {
84  trigger_error(__CLASS__ . ' will be removed in TYPO3 v12.', E_USER_DEPRECATED);
85  $pageTitle = $this->arguments['pageTitle'];
86  $includeCssFiles = $this->arguments['includeCssFiles'];
87  $includeJsFiles = $this->arguments['includeJsFiles'];
88  $addJsInlineLabels = $this->arguments['addJsInlineLabels'];
89  $includeRequireJsModules = $this->arguments['includeRequireJsModules'];
90 
91  $moduleTemplate = $this->‪getModuleTemplate();
92  $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
93 
94  // Include custom CSS and JS files
95  if (is_array($includeCssFiles) && count($includeCssFiles) > 0) {
96  foreach ($includeCssFiles as $addCssFile) {
97  $pageRenderer->addCssFile($addCssFile);
98  }
99  }
100  if (is_array($includeJsFiles) && count($includeJsFiles) > 0) {
101  foreach ($includeJsFiles as $addJsFile) {
102  $pageRenderer->addJsFile($addJsFile);
103  }
104  }
105  if (is_array($includeRequireJsModules) && count($includeRequireJsModules) > 0) {
106  foreach ($includeRequireJsModules as $addRequireJsFile) {
107  $pageRenderer->loadRequireJsModule($addRequireJsFile);
108  }
109  }
110  // Add inline language labels
111  if (is_array($addJsInlineLabels) && count($addJsInlineLabels) > 0) {
112  $extensionKey = $this->renderingContext->getRequest()->getControllerExtensionKey();
113  foreach ($addJsInlineLabels as $key) {
114  $label = ‪LocalizationUtility::translate($key, $extensionKey);
115  $pageRenderer->addInlineLanguageLabel($key, $label);
116  }
117  }
118  // Render the content and return it
119  ‪$output = $this->renderChildren();
120  if ($this->arguments['enableDocHeader'] ?? false) {
121  $moduleTemplate->getDocHeaderComponent()->enable();
122  } else {
123  $moduleTemplate->getDocHeaderComponent()->disable();
124  $moduleTemplate->getView()->setTemplate('EmptyModule.html');
125  }
126  $moduleTemplate->setTitle($pageTitle);
127  $moduleTemplate->setContent(‪$output);
128  return $moduleTemplate->renderContent();
129  }
130 }
‪TYPO3\CMS\Fluid\ViewHelpers\Be\ContainerViewHelper\initializeArguments
‪initializeArguments()
Definition: ContainerViewHelper.php:64
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility
Definition: LocalizationUtility.php:33
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper
Definition: AbstractBackendViewHelper.php:28
‪TYPO3\CMS\Fluid\ViewHelpers\Be
Definition: AbstractBackendViewHelper.php:16
‪TYPO3\CMS\Fluid\ViewHelpers\Be\ContainerViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: ContainerViewHelper.php:57
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate
‪static string null translate(string $key, ?string $extensionName=null, array $arguments=null, string $languageKey=null, array $alternativeLanguageKeys=null)
Definition: LocalizationUtility.php:67
‪TYPO3\CMS\Fluid\ViewHelpers\Be\ContainerViewHelper\render
‪string render()
Definition: ContainerViewHelper.php:81
‪$output
‪$output
Definition: annotationChecker.php:121
‪TYPO3\CMS\Fluid\ViewHelpers\Be\ContainerViewHelper
Definition: ContainerViewHelper.php:54
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper\getModuleTemplate
‪ModuleTemplate getModuleTemplate()
Definition: AbstractBackendViewHelper.php:35
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50