FluentDOM\Nodes\Modifier::insertNodesAfter PHP Méthode

insertNodesAfter() public méthode

Insert nodes after the target node.
public insertNodesAfter ( array | Traversable $contentNodes ) : array
$contentNodes array | Traversable
Résultat array
    public function insertNodesAfter($contentNodes)
    {
        $result = array();
        if ($this->_node instanceof \DOMNode && !empty($contentNodes)) {
            $beforeNode = $this->_node->nextSibling instanceof \DOMNode ? $this->_node->nextSibling : NULL;
            $hasContext = $beforeNode instanceof \DOMNode;
            foreach ($contentNodes as $contentNode) {
                /** @var \DOMNode $contentNode */
                if ($hasContext) {
                    $result[] = $this->getParentNode()->insertBefore($contentNode->cloneNode(TRUE), $beforeNode);
                } else {
                    $result[] = $this->getParentNode()->appendChild($contentNode->cloneNode(TRUE));
                }
            }
        }
        return $result;
    }