fromDocumentOrderNodeIteratorParts
@param XPath2NodeIterator $baseIter
@retun ElementOrderNodeIterator
176452
protected function fromElementOrderNodeIteratorParts( $baseIter )
	{
		$isNode = null;
		$this->itemSet = array();
		while ( $baseIter->MoveNext() )
		{
			// BMS 2018-01-08 Changed to be more careful about when getIsNode() is called
			//                Same change must be made to DocumentOrderNodeIterator
			$current = $baseIter->getCurrent();

			if ( is_null( $isNode ) )
			{
				$isNode = $current instanceof XPathNavigator && $current->getIsNode();
			}
			else
			{
				if ( ( ! $isNode && $current instanceof XPathNavigator ) || ( $isNode && $current->getIsNode() != $isNode ) )
				{
					throw XPath2Exception::withErrorCodeAndParam( "XPTY0018", Resources::XPTY0018, $baseIter->getCurrent()->getValue() );
				}
			}

			/**
			 * @var DOMXPathItem $clone
			 */
			$clone = CoreFuncs::CloneInstance( $baseIter->getCurrent() );
			$localName = $clone->getLocalName();

			$this->itemSet[ $localName ][] = $clone;
		}

		if ( ! is_null( $isNode ) && $isNode )
		{
			if ( count( $this->itemSet ) > 1 )
			{
				ksort( $this->itemSet );
			}

			foreach ( $this->itemSet as $elementName => $element )
			{
				if ( count( $element ) < 2 ) continue;

				$comparer = new XPathComparer();
				$result = usort( $this->itemSet[ $elementName ], function( $a, $b )
				{
					return strcasecmp( $a->getValue(), $b->getValue() );
				} );
			}

		}
	}
1352615
public static function fromNavigator( $context, $nav )
	{
		$nodeTest = XmlQualifiedNameTest::create();
		$iter = ChildNodeIterator::fromNodeTest( $context, $nodeTest, XPath2NodeIterator::Create( $nav ) );

		$result = new ElementOrderNodeIterator();
		$result->fromElementOrderNodeIteratorParts( $iter );
		return $result;
	}
85739
public function buildClasses($basedir, OutputInterface $output)
    {
        $target = $this->ensureBuildDir($basedir, $output);

        foreach ($this->getClasses() as $element) {
            $element->build($target, $output);
        }
    }
497206
protected function initBaseDir($basePath)
    {
        if ($basePath) {
            $this->setBaseDir($basePath);
        } elseif (defined('BASE_PATH')) {
            $this->setBaseDir(BASE_PATH);
        } else {
            throw new BadMethodCallException("No BASE_PATH defined");
        }
    }
1262888
public function findElementtypesUsingReferenceElementtype(Elementtype $referenceElementtype)
    {
        $elementtypes = array();
        foreach ($this->elementtypeManager->findAll() as $elementtype) {
            if (!$elementtype->getStructure()->getRootNode()) {
                continue;
            }
            $rii = new \RecursiveIteratorIterator($elementtype->getStructure()->getIterator(), \RecursiveIteratorIterator::SELF_FIRST);
            foreach ($rii as $node) {
                /* @var $node ElementtypeStructureNode */
                if ($node->getReferenceElementtypeId() === $referenceElementtype->getId()) {
                    $elementtypes[] = $elementtype;
                    break;
                }
            }
        }

        return $elementtypes;
    }
993895
public function initializeNode($parentId, $language, $siteId, $order = 0)
    {
        /** @var NodeInterface $node */
        $node = new $this->nodeClass();
        $node->setSiteId($siteId);
        $node->setLanguage($language);
        $node->setMaxAge(NodeInterface::MAX_AGE);
        $node->setParentId($parentId);
        $node->setOrder($order);
        $node->setVersion($this->uniqueIdGenerator->generateUniqueId());
        $node->setCreatedBy($this->tokenStorage->getToken()->getUser()->getUsername());

        $parentNode = $this->nodeRepository->findInLastVersion($parentId, $language, $siteId);
        $status = $this->statusRepository->findOneByInitial();
        $node->setStatus($status);
        $nodeType = NodeInterface::TYPE_DEFAULT;
        if ($parentNode instanceof NodeInterface) {
            $nodeType = $parentNode->getNodeType();
            $node->setPath($parentNode->getPath());
        } else {
            $node->setNodeId(NodeInterface::ROOT_NODE_ID);
        }
        $node->setNodeType($nodeType);

        return $node;
    }
1069182
protected function _mergeNodes($domElemTo, $domElemFrom, $xPathTo, $domDocTo, $queryStart)
    {
        foreach ($domElemFrom->childNodes as $fromNode) {
            if ($fromNode->nodeType === XML_ELEMENT_NODE) {
                $fromAttrName = $fromNode->getAttribute('id');
                $fromNodeName = $fromNode->tagName;

                // find current item
                $query = "{$queryStart}/{$fromNodeName}[@id='{$fromAttrName}']";
                $curNode = $xPathTo->query($query);

                // if not found - append
                if ($curNode->length == 0) {
                    $domElemTo->appendChild($domDocTo->importNode($fromNode, true));
                } else {
                    $curNode = $curNode->item(0);

                    // if found copy all attributes and check childnodes
                    $this->_copyAttributes($curNode, $fromNode);

                    if ($fromNode->childNodes->length) {
                        $this->_mergeNodes($curNode, $fromNode, $xPathTo, $domDocTo, $query);
                    }
                }
            }
        }
    }
1134850
public static function mergeNodes(SimpleXMLElement $element1, SimpleXMLElement $element2)
    {
        $document1 = new DOMDocument();
        $document2 = new DOMDocument();

        $document1->loadXML($element1->asXML());
        $document2->loadXML($element2->asXML());

        $path = new DOMXPath($document2);
        $query = $path->query('/*/*');
        $nodesCount = $query->length;

        if (0 === $nodesCount) {
            return $element1;
        }

        for ($i = 0; $i < $nodesCount; ++$i) {
            $node = $document1->importNode($query->item($i), true);
            $document1->documentElement->appendChild($node);
        }

        return simplexml_import_dom($document1);
    }
25337
protected function fromExprNodeIteratorParts( $context, $node, $dataPool, $baseIter )
	{
		$this->context = $context;
		$this->node = $node;
		$this->dataPool = $dataPool;
		$this->baseIter = $baseIter;
	}
775681
protected function _buildNodeListUntil(\DOMNode $baseNode, string $property, $input = null, $selector = null, int $matchType = null): NodeList {
        $resultNodes = $this->newNodeList();

        // Get our first node
        $node = $baseNode->$property;

        // Keep looping until we are out of nodes.
        // Allow either FIRST to reach \DOMDocument. Others that return multiple should ignore it.
        while ($node instanceof \DOMNode && ($matchType === self::$MATCH_TYPE_FIRST || !($node instanceof \DOMDocument))) {
            // Filter nodes if not matching last
            if ($matchType != self::$MATCH_TYPE_LAST && (is_null($selector) || $node->is($selector))) {
                $resultNodes[] = $node;
            }

            // 'Until' check or first match only
            if ($matchType == self::$MATCH_TYPE_FIRST || (!is_null($input) && $node->is($input))) {
                // Set last match
                if ($matchType == self::$MATCH_TYPE_LAST) {
                    $resultNodes[] = $node;
                }

                break;
            }

            // Find the next node
            $node = $node->{$property};
        }

        return $resultNodes;
    }
803449
public function recursivelyDeleteFromDirectory($baseDirectory)
    {
        if (!is_dir($baseDirectory)) {
            return;
        }

        $iterator = new \RecursiveDirectoryIterator($baseDirectory);
        $files = new \RecursiveIteratorIterator(
            $iterator,
            \RecursiveIteratorIterator::CHILD_FIRST
        );

        foreach ($files as $file) {
            $fname = $file->getFilename();
            if ($fname == '.' || $fname == '..') {
                continue;
            }

            if ($file->isDir()) {
                $this->recursivelyDeleteFromDirectory($file->getRealPath());
            } else {
                unlink($file->getRealPath());
            }
        }

        rmdir($baseDirectory);

        return;
    }
244875
public function addElement(BaseElement $element): ContainerElement
    {
        $element->parent = $this;
        $this->children[] = $element;
        if ($element instanceof ContainerElement) {
            return $element;
        }

        return $this;
    }
999601
public static function fromBaseIter( $baseIter, $allowSameElementRepeat = false )
	{
		$result = new DocumentOrderNodeIterator();
		$result->allowSameElementRepeat = $allowSameElementRepeat;
		$result->fromDocumentOrderNodeIteratorParts( $baseIter );
		return $result;
	}
615771
private function buildElementtypeStructure($rootType, $rootDsId, UserInterface $user, array $data)
    {
        $elementtypeStructure = new ElementtypeStructure();

        $sort = 1;

        $rootNode = new ElementtypeStructureNode();
        $rootNode
            ->setDsId($rootDsId)
            ->setType($rootType)
            ->setName('root')
        //    ->setSort($sort++)
        ;

        $elementtypeStructure->addNode($rootNode);

        $this->iterateData($elementtypeStructure, $rootNode, $user, $sort, $data);

        return $elementtypeStructure;
    }
1000668
public static function toDOM(BaseElement $element): \DOMDocument
    {
        $doc = new \DOMDocument('1.0', 'utf-8');
        $doc->appendChild($element->toDOM($doc));
        return $doc;
    }
703762
public function inheritMethods(&$element, &$rootDoc, &$package)
    {
        $methods =& $element->methods();
        if ($methods) {
            ksort($methods);
            $num = count($methods); $foo = 0;
            echo '<table class="inherit">', "\n";
            echo '<tr><th colspan="2">Methods inherited from ', $element->qualifiedName(), "</th></tr>\n";
            echo '<tr><td>';
            foreach ($methods as $method) {
                echo '<a href="', str_repeat('../', $this->_depth), $method->asPath(), '">', $method->name(), '</a>';
                if (++$foo < $num) {
                    echo ', ';
                }
            }
            echo '</td></tr>';
            echo "</table>\n\n";
            if ($element->superclass()) {
                $superclass =& $rootDoc->classNamed($element->superclass());
                if ($superclass) {
                    $this->inheritMethods($superclass, $rootDoc, $package);
                }
            }
        }
    }
79995
public function allowsDescendant(TemplateInspector $descendant)
	{
		// Test whether the descendant is explicitly disallowed
		if (self::match($descendant->contentBitfield, $this->denyDescendantBitfield))
		{
			return false;
		}

		// Test whether the descendant contains any elements and we disallow elements
		return ($this->allowsChildElements || !$descendant->hasElements);
	}