/**
  * Moves child to specified position. Rearange other children accordingly.
  *
  * @param \Knp\Menu\ItemInterface $child Child to move.
  * @param integer $position Position to move child to.
  * @return \Knp\Menu\ItemInterface
  */
 public function moveChildToPosition(ItemInterface $child, $position)
 {
     $name = $child->getName();
     $order = array_keys($this->children);
     $oldPosition = array_search($name, $order);
     unset($order[$oldPosition]);
     $order = array_values($order);
     array_splice($order, $position, 0, $name);
     $this->reorderChildren($order);
     return $this;
 }
Beispiel #2
0
 /**
  * @return string
  */
 public function getName()
 {
     return $this->item->getName();
 }