Cleanup specific node and his children.

@param NodeInterface $node
@param string $rootPath
@param bool $dryRun
960527
private function cleanup(OutputInterface $output, NodeInterface $node, $rootPath, $dryRun)
    {
        foreach ($node->getNodes() as $childNode) {
            $this->cleanup($output, $childNode, $rootPath, $dryRun);
        }

        $path = ltrim(str_replace($rootPath, '', $node->getPath()), '/');

        if (!$node->getPropertyValueWithDefault('sulu:history', false)) {
            $output->writeln(
                '<info>Processing aborted: </info>/' .
                $path . ' <comment>(no history url)</comment>'
            );

            return;
        }

        if (false === $dryRun) {
            $node->remove();
        }
        $output->writeln('<info>Processing: </info>/' . $path);
    }
780265
public void remove(QPath rootPath)
   {
      for (int i = items.size() - 1; i >= 0; i--)
      {
         ItemState item = items.get(i);

         QPath qPath = item.getData().getQPath();
         if (qPath.isDescendantOf(rootPath) || item.getAncestorToSave().isDescendantOf(rootPath)
            || item.getAncestorToSave().equals(rootPath) || qPath.equals(rootPath))
         {
            
            if (item.isNode())
            {
               removeNode(item, i);
            }
            else
            {
               removeProperty(item, i);
            }
         }
      }
   }
233005
protected function filterNodeByContext(NodeInterface $node, Context $context)
    {
        $this->securityContext->withoutAuthorizationChecks(function () use (&$node, $context) {
            if (!$context->isRemovedContentShown() && $node->isRemoved()) {
                $node = null;
                return;
            }
            if (!$context->isInvisibleContentShown() && !$node->isVisible()) {
                $node = null;
                return;
            }
            if (!$context->isInaccessibleContentShown() && !$node->isAccessible()) {
                $node = null;
            }
        });
        return $node;
    }
339604
public function remove($path)
    {
        list($name, $path) = $this->splitPath($path);

        if (empty($path)) {
            throw new RuntimeException('The root node of config is not writable');
        }

        return $this->load($name)->remove($path);
    }
543311
public function handle(NodeInterface $node, array $data)
    {
        if ($node->getNodeType()->isOfType('Neos.Neos:Document')) {
            if (isset($data['title'])) {
                $node->setProperty('title', $data['title']);
            }
            $node->setProperty('uriPathSegment', $this->nodeUriPathSegmentGenerator->generateUriPathSegment($node, (isset($data['title']) ? $data['title'] : null)));
        }
    }
146328
public function invoke($node, NodeInterface $parent): void
    {
        if (! $node instanceof Node\Stmt\GroupUse || ! $parent instanceof PhpFileModelInterface) {
            throw new Exception('GroupUseNodeParser is made to parse a use group node');
        }

        if ($this->validateType($node->type)) {
            $prefix = $node->prefix->toString();
            foreach ($node->uses as $use) {
                if ($this->validateType($node->type)) {
                    $parent->addUse($use->getAlias()->name, $prefix . '\\' . $use->name->toString());
                }
            }
        }
    }
1121003
public void rebuildNode(String fullPath) throws Exception
    {
        Preconditions.checkArgument(ZKPaths.getPathAndNode(fullPath).getPath().equals(path), "Node is not part of this cache: " + fullPath);
        Preconditions.checkState(!executorService.isShutdown(), "cache has been closed");

        ensurePath();
        internalRebuildNode(fullPath);

        // this is necessary so that any updates that occurred while rebuilding are taken
        // have to rebuild entire tree in case this node got deleted in the interim
        offerOperation(new RefreshOperation(this, RefreshMode.FORCE_GET_DATA_AND_STAT));
    }
460986
public function copyNode(NodeInterface $node)
    {
        $this->nodeContextPath = $node->getContextPath();
        $this->mode = self::MODE_COPY;
    }
1012441
public function removeNode(StreamServerNodeInterface $node)
    {
        if (!isset($this->nodes[(int)$node->socket])) {
            $this->logger->error("Trying to remove nonexistent node - if there's no information regarding server overload it can indicate internal bug.");
            return;
        }

        unset($this->nodes[(int)$node->socket]);
        $this->nodesCount--;
        $this->logger->info("Node $node removed from server");
    }
967292
public function nodePathAvailableForNode($nodePath, NodeInterface $node)
    {
        /** @var NodeData $existingNodeData */
        $existingNodeDataObjects = $this->nodeDataRepository->findByPathWithoutReduce($nodePath, $node->getWorkspace(), true);
        foreach ($existingNodeDataObjects as $existingNodeData) {
            if ($existingNodeData->getMovedTo() !== null && $existingNodeData->getMovedTo() === $node->getNodeData()) {
                return true;
            }
        }
        return !$this->nodePathExistsInAnyContext($nodePath);
    }
338988
protected function reindex(array $nodes, int &$reindexed, SymfonyStyle $io, array $context, int $batch, bool $dryRun = false, bool $skipErrors = false): void
    {
        if ($dryRun) {
            $io->note(sprintf('DRY RUN - Would reindex node batch %d here.', $batch));
        } else {
            try {
                $this->ncrSearch->indexNodes($nodes, $context);
            } catch (\Throwable $e) {
                $io->error($e->getMessage());
                $io->note(sprintf('Failed to index batch %d.', $batch));
                $io->newLine(2);

                if (!$skipErrors) {
                    throw $e;
                }
            }
        }

        $reindexed += count($nodes);
    }
210600
protected function syncEnvironmentPaths($paths, $project, $dryRun = false) {
		$list = $project->Environments();

		// Normalise paths in DB
		foreach($list as $item) {
			$real = realpath($item->Filename);
			if($real && $real != $item->Filename) {
				$item->Filename = $real;
				$item->write();
			}
		}

		foreach($paths as $path) {
			$path = basename($path);
			if($list->filter('Filename', $path)->count()) {
				continue;
			}

			$this->message('Adding "'.basename($path).'" to db');
			if(!$dryRun) {
				$environment = DNEnvironment::create_from_path($path);
				$environment->ProjectID = $project->ID;
				$environment->write();
			}
		}
	}
831004
public function createChildNodes(NodeInterface $node)
    {
        $nodeType = $node->getNodeType();
        foreach ($nodeType->getAutoCreatedChildNodes() as $childNodeName => $childNodeType) {
            try {
                $node->createNode($childNodeName, $childNodeType);
            } catch (NodeExistsException $exception) {
                // If you have a node that has been marked as removed, but is needed again
                // the old node is recovered
                $childNodePath = NodePaths::addNodePathSegment($node->getPath(), $childNodeName);
                $contextProperties = $node->getContext()->getProperties();
                $contextProperties['removedContentShown'] = true;
                $context = $this->contextFactory->create($contextProperties);
                $childNode = $context->getNode($childNodePath);
                if ($childNode->isRemoved()) {
                    $childNode->setRemoved(false);
                }
            }
        }
    }
1128396
protected function moveNodeToDestinationPath(NodeInterface $node, $destinationPath)
    {
        $nodeData = $node->getNodeData();
        $possibleShadowedNodeData = $nodeData->move($destinationPath, $this->context->getWorkspace());
        if ($node instanceof Node) {
            $node->setNodeData($possibleShadowedNodeData);
        }
    }
1124008
public function free(Node\NodeInterface $node = null)
	{
		if (is_null($node)) {
			$this->arrayHelper->free();
		} else {
			$this->arrayHelper->free($node);
		}
	}
791832
public function updateNode(TreeNodeInterface $node, $flush = true)
    {
        $node->setSiterootId($this->siterootId);

        $this->entityManager->persist($node);
        if ($flush) {
            $this->entityManager->flush($node);
        }

        return $this;
    }
432116
protected function _cleanEmptyParents($dom, $parentXPath, $childXPath)
    {
        $xPath = new DomXPath($dom);
        $nodeList = $xPath->query($parentXPath);

        foreach ($nodeList as $node) {
            $id = $node->getAttribute('id');
            $childList = $xPath->query("{$parentXPath}[@id='$id']/$childXPath");
            if (!$childList->length) {
                $node->parentNode->removeChild($node);
            }
        }
    }