Module: Check a menu item's permission and don't overwrite its label

This allows now totally different values for an item's name and label
and fixes the bug that permissions declared in the configuration.php
were not evaluated for menu items.

fixes #11431
This commit is contained in:
Johannes Meyer 2016-09-26 11:00:42 +02:00
parent 5b875f3749
commit 7ed3acbbd8
1 changed files with 11 additions and 8 deletions

View File

@ -362,25 +362,28 @@ class Module
public function getMenu()
{
$this->launchConfigScript();
return $this->createMenu($this->menuItems);
return Navigation::fromArray($this->createMenu($this->menuItems));
}
/**
* Create and return a new navigation for the given menu items
* Create and return an array structure for the given menu items
*
* @param MenuItemContainer[] $items
*
* @return Navigation
* @return array
*/
private function createMenu(array $items)
{
$navigation = new Navigation();
$navigation = array();
foreach ($items as $item) {
/** @var MenuItemContainer $item */
$navigationItem = $navigation->createItem($item->getName(), $item->getProperties());
$navigationItem->setChildren($this->createMenu($item->getChildren()));
$navigationItem->setLabel($this->translate($item->getName()));
$navigation->addItem($navigationItem);
$properties = $item->getProperties();
$properties['children'] = $this->createMenu($item->getChildren());
if (! isset($properties['label'])) {
$properties['label'] = $this->translate($item->getName());
}
$navigation[$item->getName()] = $properties;
}
return $navigation;