/** * @param NodeInterface $node * @return $this */ protected function writeInternal(NodeInterface $node) { $len = 1; if ($node->getAttributes() != null) { $len += count($node->getAttributes()) * 2; } if (count($node->getChildren()) > 0) { $len += 1; } if (strlen($node->getData()) > 0) { $len += 1; } $this->writeListStart($len); $this->writeString($node->getName()); $this->writeAttributes($node->getAttributes()); if (strlen($node->getData()) > 0) { $this->writeBytes($node->getData()); } if ($node->getChildren()) { $this->writeListStart(count($node->getChildren())); foreach ($node->getChildren() as $child) { $this->writeInternal($child); } } return $this; }
/** * @param NodeInterface $node * @return Group[] */ protected function getGroupsFromNode(NodeInterface $node) { $groupList = array(); if ($node->getChild(0) != null) { foreach ($node->getChildren() as $child) { $groupList[] = Group::factory($child->getAttributes()); } } return $groupList; }