[TASK] Move arguments to initializeArguments() in ActionMenuItemGroupVH in ext:fluid
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Be / Menus / ActionMenuItemGroupViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers\Be\Menus;
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 use TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode;
17 use TYPO3Fluid\Fluid\Core\Compiler\TemplateCompiler;
18
19 /**
20 * View helper which groups options of an option tag.
21 *
22 * = Example =
23 *
24 * <f:be.menus.actionMenu>
25 * <f:be.menus.actionMenuItem label="Default: Welcome" controller="Default" action="index" />
26 * <f:be.menus.actionMenuItem label="Community: get in touch" controller="Community" action="index" />
27 *
28 * <f:be.menus.actionMenuItemGroup label="Information">
29 * <f:be.menus.actionMenuItem label="PHP Information" controller="Information" action="listPhpInfo" />
30 * <f:be.menus.actionMenuItem label="Documentation" controller="Information" action="documentation" />
31 * <f:be.menus.actionMenuItem label="Hooks" controller="Information" action="hooks" />
32 * <f:be.menus.actionMenuItem label="Signals" controller="Information" action="signals" />
33 * <f:be.menus.actionMenuItem label="XClasses" controller="Information" action="xclass" />
34 * </f:be.menus.actionMenuItemGroup>
35 * </f:be.menus.actionMenu>
36 *
37 */
38 class ActionMenuItemGroupViewHelper extends ActionMenuViewHelper
39 {
40 /**
41 * @var string
42 */
43 protected $tagName = 'optgroup';
44
45 /**
46 * Initialize arguments.
47 *
48 * @api
49 * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
50 */
51 public function initializeArguments()
52 {
53 parent::initializeArguments();
54 $this->registerArgument('label', 'string', 'label', false, '');
55 }
56
57 /**
58 * @return string
59 */
60 public function render()
61 {
62 $label = $this->arguments['label'];
63
64 $this->tag->addAttribute('label', $label);
65 $options = '';
66 foreach ($this->childNodes as $childNode) {
67 if ($childNode instanceof ViewHelperNode && $childNode->getViewHelperClassName() === ActionMenuItemViewHelper::class) {
68 $options .= $childNode->evaluate($this->renderingContext);
69 }
70 }
71 $this->tag->setContent($options);
72 return $this->tag->render();
73 }
74
75 /**
76 * @param string $argumentsName
77 * @param string $closureName
78 * @param string $initializationPhpCode
79 * @param ViewHelperNode $node
80 * @param TemplateCompiler $compiler
81 * @return null
82 */
83 public function compile($argumentsName, $closureName, &$initializationPhpCode, ViewHelperNode $node, TemplateCompiler $compiler)
84 {
85 // @TODO: replace with a true compiling method to make compilable!
86 $compiler->disable();
87 return null;
88 }
89 }