QueryPath\DOMQuery::wrapAll PHP Метод

wrapAll() публичный Метод

So all elements will be grouped together under this single marked up item. This works by first determining the parent element of the first item in the list. It then moves all of the matching elements under the wrapper and inserts the wrapper where that first element was found. (This is in accordance with the way jQuery works.) Markup is usually XML in a string, but it can also be a DOMNode, a document fragment, a SimpleXMLElement, or another DOMNode object (in which case the first item in the list will be used.)
См. также: wrap()
См. также: wrapInner()
public wrapAll ( string $markup )
$markup string Markup that will wrap all elements in the current list.
    public function wrapAll($markup)
    {
        if ($this->matches->count() == 0) {
            return;
        }
        $data = $this->prepareInsert($markup);
        if (empty($data)) {
            return $this;
        }
        if ($data instanceof \DOMDocumentFragment) {
            $data = $data->firstChild->cloneNode(true);
        } else {
            $data = $data->cloneNode(true);
        }
        if ($data->hasChildNodes()) {
            $deepest = $this->deepestNode($data);
            // FIXME: Does this need fixing?
            $bottom = $deepest[0];
        } else {
            $bottom = $data;
        }
        $first = $this->getFirstMatch();
        $parent = $first->parentNode;
        $parent->insertBefore($data, $first);
        foreach ($this->matches as $m) {
            $bottom->appendChild($m->parentNode->removeChild($m));
        }
        return $this;
    }