[TASK] Move ViewHelper arguments to initializeArguments() in ext:install
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / ViewHelpers / Be / ContainerViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Install\ViewHelpers\Be;
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
17 /**
18 * View helper which allows you to create extbase based modules in the
19 * style of TYPO3 default modules.
20 * Note: This feature is experimental!
21 *
22 * = Examples =
23 *
24 * <code title="Simple">
25 * <f:be.container>your module content</f:be.container>
26 * </code>
27 * <output>
28 * "your module content" wrapped with proper head & body tags.
29 * Default backend CSS styles and JavaScript will be included
30 * </output>
31 *
32 * <code title="All options">
33 * <f:be.container pageTitle="foo">your module content</f:be.container>
34 * </code>
35 * <output>
36 * "your module content" wrapped with proper head & body tags.
37 * Custom CSS file EXT:your_extension/Resources/Public/styles/backend.css and JavaScript file EXT:your_extension/Resources/Public/scripts/main.js will be loaded
38 * </output>
39 *
40 * @internal
41 */
42 class ContainerViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper
43 {
44 /**
45 * @var bool
46 */
47 protected $escapeOutput = false;
48
49 /**
50 * @var bool
51 */
52 protected $escapeChildren = false;
53
54 /**
55 * Initialize arguments
56 */
57 public function initializeArguments()
58 {
59 parent::initializeArguments();
60 $this->registerArgument('pageTitle', 'string', 'title tag of the module. Not required by default, as BE modules are shown in a frame', false, '');
61 $this->registerArgument('addCssFiles', 'array', 'Custom CSS files to be loaded', false, []);
62 $this->registerArgument('addJsFiles', 'array', 'Custom JavaScript files to be loaded', false, []);
63 }
64
65 /**
66 * Render start page with \TYPO3\CMS\Backend\Template\DocumentTemplate and pageTitle
67 *
68 * @return string
69 * @see \TYPO3\CMS\Backend\Template\DocumentTemplate
70 * @see \TYPO3\CMS\Core\Page\PageRenderer
71 */
72 public function render()
73 {
74 $pageTitle = $this->arguments['pageTitle'];
75 $addCssFiles = $this->arguments['addCssFiles'];
76 $addJsFiles = $this->arguments['addJsFiles'];
77
78 $doc = $this->getDocInstance();
79 $pageRenderer = $this->getPageRenderer();
80
81 if (is_array($addCssFiles) && !empty($addCssFiles)) {
82 foreach ($addCssFiles as $addCssFile) {
83 $pageRenderer->addCssFile($addCssFile);
84 }
85 }
86 if (is_array($addJsFiles) && !empty($addJsFiles)) {
87 foreach ($addJsFiles as $addJsFile) {
88 $pageRenderer->addJsFile($addJsFile);
89 }
90 }
91 $output = $this->renderChildren();
92 $output = $doc->startPage($pageTitle) . $output;
93 $output .= $doc->endPage();
94 return $output;
95 }
96 }