TYPO3  7.6
MenuRegistry.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\Template\Components;
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 
19 
24 {
30  protected $menus = [];
31 
41  public function addMenu(Menu $menu)
42  {
43  if (!$menu->isValid($menu)) {
44  throw new \InvalidArgumentException('Menu "' . $menu->getIdentifier() . '" is not valid', 1442236362);
45  }
46  $this->menus[$menu->getIdentifier()] = clone $menu;
47  }
48 
54  public function getMenus()
55  {
56  // @todo do we want to provide a hook here?
63  foreach ($this->menus as $key => $menu) {
64  if (empty($menu->getMenuItems())) {
65  unset($this->menus[$key]);
66  }
67  }
68  return $this->menus;
69  }
70 
76  public function makeMenu()
77  {
78  $menu = GeneralUtility::makeInstance(Menu::class);
79  return $menu;
80  }
81 }