‪TYPO3CMS  10.4
MenuRegistry.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 
20 
25 {
31  protected ‪$menus = [];
32 
40  public function ‪addMenu(‪Menu $menu)
41  {
42  if (!$menu->‪isValid($menu)) {
43  throw new \InvalidArgumentException('Menu "' . $menu->‪getIdentifier() . '" is not valid', 1442236362);
44  }
45  $this->menus[$menu->‪getIdentifier()] = clone $menu;
46  }
47 
53  public function getMenus()
54  {
55  // @todo do we want to provide a hook here?
62  foreach ($this->menus as $key => $menu) {
63  if (empty($menu->‪getMenuItems())) {
64  unset($this->menus[$key]);
65  }
66  }
67  return ‪$this->menus;
68  }
69 
75  public function ‪makeMenu()
76  {
77  $menu = GeneralUtility::makeInstance(Menu::class);
78  return $menu;
79  }
80 }
‪TYPO3\CMS\Backend\Template\Components\MenuRegistry\$menus
‪array $menus
Definition: MenuRegistry.php:30
‪TYPO3\CMS\Backend\Template\Components\MenuRegistry
Definition: MenuRegistry.php:25
‪TYPO3\CMS\Backend\Template\Components\Menu\Menu\getMenuItems
‪array getMenuItems()
Definition: Menu.php:101
‪TYPO3\CMS\Backend\Template\Components\MenuRegistry\makeMenu
‪Menu makeMenu()
Definition: MenuRegistry.php:74
‪TYPO3\CMS\Backend\Template\Components\Menu\Menu\getIdentifier
‪string getIdentifier()
Definition: Menu.php:111
‪TYPO3\CMS\Backend\Template\Components\Menu\Menu\isValid
‪bool isValid(Menu $menu)
Definition: Menu.php:146
‪TYPO3\CMS\Backend\Template\Components\Menu\Menu
Definition: Menu.php:24
‪TYPO3\CMS\Backend\Template\Components
Definition: AbstractControl.php:16
‪TYPO3\CMS\Backend\Template\Components\MenuRegistry\addMenu
‪addMenu(Menu $menu)
Definition: MenuRegistry.php:39
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46