Exemple #1
0
 /**
  * Add new settings meta info.
  *
  * @param Meta $meta
  */
 public function addMeta(Meta $meta)
 {
     $group = $meta->getGroup();
     if (!$this->groups->has($group)) {
         $this->groups->put($group, new Collection());
     }
     if ($this->all->has($meta->getName())) {
         throw new \RuntimeException('Settings with name `' . $meta->getName() . '` already exists .');
     }
     $this->all->put($meta->getName(), $meta);
     //$this->groups->get($group);
     $this->groups->get($group)->put($meta->getName(), $meta);
 }
 /**
  * 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;
 }