Example #1
0
 /**
  * Add another Menu instance and combined the two
  * Groups with the same name get combined, but
  * inherit each other's items
  *
  * @param Menu $menu
  *
  * @return Menu $menu
  */
 public function add(Menu $menu)
 {
     foreach ($menu->getGroups() as $group) {
         if ($this->groups->has($group->getName())) {
             $existingGroup = $this->groups->get($group->getName());
             $group->hideHeading(!$group->shouldShowHeading());
             foreach ($group->getItems() as $item) {
                 $existingGroup->addItem($item);
             }
         } else {
             $this->addGroup($group);
         }
     }
     return $this;
 }