*
* @param IFormChildNode $child appended child
* @return static this node
- *
- * @throws \InvalidArgumentException if the given child node cannot be appended
*/
public function appendChild(IFormChildNode $child);
*
* @param IFormChildNode[] $children appended children
* @return static this node
- *
- * @throws \InvalidArgumentException if any of the given child nodes is invalid or cannot be appended
*/
public function appendChildren(array $children);
public function readValues();
/**
- * Checks if the given node can be added as a child to this node.
+ * Checks if the given node is a valid child for this node.
*
* @param IFormChildNode $child validated child node
*
- * @throws \InvalidArgumentException if given node cannot be added as a child
+ * @throws \InvalidArgumentException if given node cannot is an invalid child
*/
public function validateChild(IFormChildNode $child);
}
*
* @param IFormChildNode $child appended child
* @return static this node
- *
- * @throws \InvalidArgumentException if the given child node cannot be appended
*/
public function appendChild(IFormChildNode $child) {
- $this->validateChild($child);
-
$this->children[] = $child;
$child->parent($this);
*
* @param IFormChildNode[] $children appended children
* @return static this node
- *
- * @throws \InvalidArgumentException if any of the given child nodes is invalid or cannot be appended
*/
public function appendChildren(array $children) {
foreach ($children as $child) {
* @throws \InvalidArgumentException if given node cannot be added as a child
*/
public function validateChild(IFormChildNode $child) {
- // check if a node with same id as the given node already exists
- if ($this->contains($child->getId())) {
- throw new \InvalidArgumentException("Cannot append node '{$child->getId()}' to node '{$this->getId()}' because a node with id '{$child->getId()}' already exists.");
- }
-
- // check all child nodes of the given node for duplicate node ids
- if ($child instanceof IFormParentNode) {
- /** @var IFormNode $thisChild */
- foreach ($child->getIterator() as $grandChild) {
- if ($grandChild instanceof IFormParentNode && $this->contains($grandChild->getId())) {
- throw new \InvalidArgumentException("Cannot append node '{$child->getId()}' to node '{$this->getId()}' because '{$child->getId()}' contains a node with id '{$grandChild->getId()}' that is already used by another node.");
- }
- }
- }
+ // does nothing
}
}