/** * @expectedException Magento_Exception */ public function testReorderChildException() { $this->_structure->createElement('one', array()); $this->_structure->createElement('two', array()); $this->_structure->reorderChild('one', 'two', 0); }
/** * Reorder a child of a specified element * * If $offsetOrSibling is null, it will put the element to the end * If $offsetOrSibling is numeric (integer) value, it will put the element after/before specified position * Otherwise -- after/before specified sibling * * @param string $parentName * @param string $childName * @param string|int|null $offsetOrSibling * @param bool $after */ public function reorderChild($parentName, $childName, $offsetOrSibling, $after = true) { if (is_numeric($offsetOrSibling)) { $offset = (int) abs($offsetOrSibling) * ($after ? 1 : -1); $this->_structure->reorderChild($parentName, $childName, $offset); } elseif (null === $offsetOrSibling) { $this->_structure->reorderChild($parentName, $childName, null); } else { $children = $this->getChildNames($parentName); $sibling = $this->_filterSearchMinus($offsetOrSibling, $children, $after); if ($childName !== $sibling) { $siblingParentName = $this->_structure->getParentId($sibling); if ($parentName !== $siblingParentName) { Mage::log("Broken reference: the '{$childName}' tries to reorder itself towards '{$sibling}', " . "but their parents are different: '{$parentName}' and '{$siblingParentName}' respectively.", Zend_Log::CRIT); return; } $this->_structure->reorderToSibling($parentName, $childName, $sibling, $after ? 1 : -1); } } }