public function setIndentationLevel($level) { $oldLevel = $this->getIndentationLevel(); parent::setIndentationLevel($level); $this->_spaces = $this->createSpaces(); if ($this->hasChildren()) { $children = $this->getChildren(); for ($i = 0, $len = count($children); $i < $len; $i++) { $childNode = $children[$i]; $currentLevel = $this->getIndentationLevel(); $childLevel = $childNode->getIndentationLevel(); $oldDiff = $childLevel - $oldLevel; $newLevel = $currentLevel + $oldDiff; $childNode->setIndentationLevel($newLevel); } } }