insert a MenuEntry before an existing MenuEntry

@param MenuEntry $new
@param MenuEntry $pos
@return Menu
423836
public function insertBeforeEntry(MenuEntry $new, MenuEntry $pos) {

		foreach($this->entries as $k => $e) {
			if($e === $pos) {
				$this->insertEntry($new, $k);
				break;
			}
		}
		
		return $this;

	}
123543
protected function newLogEntry(
        /*# string */ $channel,
        /*# string */ $level,
        /*# string */ $message,
        array $context = []
    )/*# : EventInterface */ {
        if (is_null($this->entry_proto)) {
            return new LogEntry($channel, $level, $message, $context);
        } else {
            $entry = clone $this->entry_proto;
            return $entry
                ->setChannel($channel)
                ->setLevel($level)
                ->setMessage($message)
                ->setContext($context)
                ->setTimestamp();
        }
    }
245180
public function arrayReplaceAt($src, $pos, $newElements)
    {
        if(empty($newElements))$newElements=[];
        return array_merge(array_slice($src, 0, $pos), $newElements, array_slice($src, $pos + 1));
    }
223008
public function reprioritise($entry, $newPriority, $oldPriority = false)
    {
        $changedAnything = false;
        foreach ($this->entries as $i => &$entryData) {
            if ($entry === $entryData['data'] && ($oldPriority === false || $entryData['priority'] == $oldPriority)) {
                $entryData['priority'] = $newPriority;
                $changedAnything = true;
            }
        }
        if ($changedAnything) {
            $this->sorted = false;
        }
        return $this;
    }
756953
public function setByPosition($pos, $value)
    {
        switch ($pos) {
            case 0:
                $this->setMediaId($value);
                break;
            case 1:
                $this->setPageId($value);
                break;
        } // switch()

        return $this;
    }
844353
private function addExtend(MenuEntry $root)
    {
        $root->add(
            MenuEntry::create('extensions')
                ->setRoute('extensions')
                ->setLabel(Trans::__('general.phrase.extensions-overview'))
                ->setIcon('fa:cubes')
                ->setPermission('extensions')
        );

        // Extension supplied entries
        $root->add(
            MenuEntry::create('custom')
                ->setRoute('extensions')
                ->setPermission('settings')
        );
    }
759888
protected function insertEntry(MenuEntry $entry, $ndx = NULL) {

		if($entry instanceof DynamicMenuEntry) {
			$this->dynamicEntries[] = $entry;
		}

		if(!isset($ndx) || $ndx >= count($this->entries)) {
			$this->entries[] = $entry;
		}
		else {
			array_splice($this->entries, $ndx, 0, [$entry]);
		}

		$entry->setMenu($this);
		
		return $this;

	}
886036
def insert_before(self, key, new_item, instance=0):
        """"""
        self._insert_item(key, new_item, instance, False)
676777
public function setByPosition($pos, $value)
    {
        switch ($pos) {
            case 0:
                $this->setId($value);
                break;
            case 1:
                $this->setTitle($value);
                break;
            case 2:
                $this->setHost($value);
                break;
            case 3:
                $this->setEndpoint($value);
                break;
            case 4:
                $this->setCreatedAt($value);
                break;
            case 5:
                $this->setUpdatedAt($value);
                break;
        } // switch()

        return $this;
    }
946378
protected function addNestedValue(string $key, $value, int $pos)
    {
        # convert the levels into an array of strings
        $levels = (strpos($key, "][") !== false)
            ? explode("][", substr($key, $pos + 1, -1))
            : [substr($key, $pos + 1, -1)];

        array_unshift($levels, substr($key, 0, $pos));

        # ensure the nesting doesn't exceed `max_nesting_levels`
        $levelLen = count($levels);
        if ($levelLen > $this->maxNestingLevels) {
            throw new DecodeException("max_input_nesting_level exceeded");
        }

        $lastKey = array_pop($levels);
        $values = &$this->values;
        foreach ($levels as $level) {
            if ($level === "") {
                $level = count($values);
            }
            if (!array_key_exists($level, $values)) {
                $values[$level] = [];
            }
            $values = &$values[$level];
        }

        if ($lastKey === "") {
            $lastKey = count($values);
        }

        \sndsgd\Arr::addValue($values, $lastKey, $value);
    }
638692
public function addMenuEntry($location, MenuEntry $menuEntry, $priority = 50)
    {
        if (!isset($this->menuEntries[$location])) {
            $this->menuEntries[$location] = array();
        }
        
        if (!isset($this->menuEntries[$location][$priority])) {
            $this->menuEntries[$location][$priority] = array();
        }

        if (isset($this->menuEntries[$location][$priority][$menuEntry->getKey()])) {
            return false;
        }
        
        $this->menuEntries[$location][$priority][$menuEntry->getKey()] = $menuEntry;
        
        ksort($this->menuEntries[$location]);
        uasort($this->menuEntries[$location][$priority], array($this, 'sortMenuEntries'));
        
        return true;
    }
1187121
public function getDescendantNodeAtPosition(int $pos) {
        foreach ($this->getChildNodes() as $child) {
            if ($child->containsPosition($pos)) {
                $node = $child->getDescendantNodeAtPosition($pos);
                if (!is_null($node)) {
                    return $node;
                }
            }
        }

        return $this;
    }
324965
public function upMenuPagesPosition($menuName, $position, $positionLimit = NULL)
    {
        if (is_null($positionLimit))
        {
            $query = $this->getEntityManager()->createQuery('UPDATE FulgurioLightCMSBundle:PageMenu m SET m.position=m.position-1 WHERE m.position>=:position AND m.label=:menuName');
        }
        else
        {
            $query = $this->getEntityManager()->createQuery('UPDATE FulgurioLightCMSBundle:PageMenu m SET m.position=m.position-1 WHERE m.position>=:position AND m.position<=:positionLimit AND m.label=:menuName');
            $query->setParameter('positionLimit', $positionLimit);
        }
        $query->setParameter('menuName', $menuName);
        $query->setParameter('position', $position);
        $query->getResult();
    }
1042013
public function setByPosition($pos, $value)
    {
        switch ($pos) {
            case 0:
                $this->setSkillId($value);
                break;
            case 1:
                $this->setGroupId($value);
                break;
        } // switch()

        return $this;
    }
370016
protected function mergeMenuPresenceData(MenuPresenceInterface $original, MenuPresenceInterface $new)
    {
        $keys = $new->explicitKeys();

        foreach ($keys as $key) {
            $original->{$key} = $new->{$key};
        }

        return $original;
    }
579855
function insertOrAppend(container, pos, el) {
    var childs = container.childNodes;
    if (pos < childs.length) {
      var refNode = childs[pos];
      container.insertBefore(el, refNode);
    } else {
      container.appendChild(el);
    }
  }
454466
public function addChild(MenuEntry $child)
    {
        if (isset($this->children[$child->getKey()])) {
            return false;
        }
        
        $this->children[$child->getKey()] = $child;
        
        // Sets this MenuEntry as parent of the child
        $child->setParent($this);
        
        return true;
    }