/** * Updated items children. */ protected function updateChildren() { $children = $this->manager->getChildren($this->item->name); $childrenNames = array_keys($children); if (is_array($this->children)) { // remove children that foreach (array_diff($childrenNames, $this->children) as $item) { $this->manager->removeChild($this->item, $children[$item]); } // add new children foreach (array_diff($this->children, $childrenNames) as $item) { $this->manager->addChild($this->item, $this->manager->getItem($item)); } } else { $this->manager->removeChildren($this->item); } }