[TASK] Streamline phpdoc annotations 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
17 use TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\ViewHelperNode;
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 class ActionMenuItemGroupViewHelper extends ActionMenuViewHelper
38 {
39 /**
40 * @var string
41 */
42 protected $tagName = 'optgroup';
43
44 /**
45 * Initialize arguments.
46 *
47 * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
48 */
49 public function initializeArguments()
50 {
51 parent::initializeArguments();
52 $this->registerArgument('label', 'string', 'label', false, '');
53 }
54
55 /**
56 * @return string
57 */
58 public function render()
59 {
60 $label = $this->arguments['label'];
61
62 $this->tag->addAttribute('label', $label);
63 $options = '';
64 foreach ($this->childNodes as $childNode) {
65 if ($childNode instanceof ViewHelperNode && $childNode->getViewHelperClassName() === ActionMenuItemViewHelper::class) {
66 $options .= $childNode->evaluate($this->renderingContext);
67 }
68 }
69 $this->tag->setContent($options);
70 return $this->tag->render();
71 }
72 }