Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
add method to remove MenuItem from menu (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
lduer authored and kevinpapst committed Jan 14, 2020
1 parent e0bc90e commit f5a450b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Event/MenuEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ public function addItem($item)
return $this;
}

/**
* @param MenuItemInterface|MenuItem|string $item
* @return MenuEvent
*/
public function removeItem($item): MenuEvent
{
if ($item instanceof MenuItemInterface && isset($this->menuRootItems[$item->getIdentifier()])) {
unset($this->menuRootItems[$item->getIdentifier()]);
} elseif (is_string($item) && isset($this->menuRootItems[$item])) {
unset($this->menuRootItems[$item]);
}

return $this;
}

/**
* @param string $id
* @return MenuItemInterface|MenuItem|null
Expand Down

0 comments on commit f5a450b

Please sign in to comment.