From 3d55e7c76ed8780b20fdd1fbcb7d15e31185a4ae Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 12 Oct 2023 23:56:54 +0200 Subject: [PATCH] TASK: Remove unused `NodeTreeBuilder` --- .../Controller/BackendServiceController.php | 12 - Classes/Domain/Service/NodeTreeBuilder.php | 225 ------------------ 2 files changed, 237 deletions(-) delete mode 100644 Classes/Domain/Service/NodeTreeBuilder.php diff --git a/Classes/Controller/BackendServiceController.php b/Classes/Controller/BackendServiceController.php index 7c923fbcec..206e8e8923 100644 --- a/Classes/Controller/BackendServiceController.php +++ b/Classes/Controller/BackendServiceController.php @@ -47,7 +47,6 @@ use Neos\Neos\Ui\Domain\Model\Feedback\Operations\ReloadDocument; use Neos\Neos\Ui\Domain\Model\Feedback\Operations\UpdateWorkspaceInfo; use Neos\Neos\Ui\Domain\Model\FeedbackCollection; -use Neos\Neos\Ui\Domain\Service\NodeTreeBuilder; use Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper; use Neos\Neos\Ui\Fusion\Helper\WorkspaceHelper; use Neos\Neos\Ui\Service\NodeClipboard; @@ -484,17 +483,6 @@ public function initializeLoadTreeAction(): void $this->arguments['nodeTreeArguments']->getPropertyMappingConfiguration()->allowAllProperties(); } - /** - * Load the nodetree - */ - public function loadTreeAction(NodeTreeBuilder $nodeTreeArguments, bool $includeRoot = false): void - { - $contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId; - - $nodeTreeArguments->setControllerContext($this->controllerContext); - $this->view->assign('value', $nodeTreeArguments->build($contentRepositoryId, $includeRoot)); - } - /** * @throws \Neos\Flow\Mvc\Exception\NoSuchArgumentException */ diff --git a/Classes/Domain/Service/NodeTreeBuilder.php b/Classes/Domain/Service/NodeTreeBuilder.php deleted file mode 100644 index acab3f73e5..0000000000 --- a/Classes/Domain/Service/NodeTreeBuilder.php +++ /dev/null @@ -1,225 +0,0 @@ -rootContextPath = $rootContextPath; - } - - /** - * Get the root node - * - * @return Node - */ - private function getRoot() - { - if (!$this->root) { - $this->root = $this->active->getContext()->getCurrentSiteNode(); - } - - return $this->root; - } - - /** - * Set the active node - * - * @param string $activeContextPath - * @return void - */ - public function setActive($activeContextPath) - { - $this->activeContextPath = $activeContextPath; - } - - /** - * Set the node type filter - * - * @param string $nodeTypeFilter - * @return void - */ - public function setNodeTypeFilter($nodeTypeFilter) - { - $this->nodeTypeFilter = $nodeTypeFilter; - } - - /** - * Set the search term filter - * - * @param string $searchTermFilter - * @return void - */ - public function setSearchTermFilter($searchTermFilter) - { - $this->searchTermFilter = $searchTermFilter; - } - - /** - * Set the depth - * - * @param integer $depth - */ - public function setDepth($depth) - { - $this->depth = $depth; - } - - /** - * Set the controller context - * - * @param ControllerContext $controllerContext - * @return void - */ - public function setControllerContext(ControllerContext $controllerContext) - { - $this->controllerContext = $controllerContext; - } - - /** - * Build a json serializable tree structure containing node information - * - * @param bool $includeRoot - * @param null $root - * @param null $depth - * @return array - */ - public function build(ContentRepositoryId $contentRepositoryId, $includeRoot = false, $root = null, $depth = null) - { - $root = $root === null ? $this->getRoot() : $root; - $depth = $depth === null ? $this->depth : $depth; - - $result = []; - - /** @var Node $childNode */ - foreach ($root->getChildNodes($this->nodeTypeFilter) as $childNode) { - $hasChildNodes = $childNode->hasChildNodes($this->nodeTypeFilter); - $shouldLoadChildNodes = $hasChildNodes && ($depth > 1 || $this->isInRootLine($this->active, $childNode)); - - $result[$childNode->getName()] = [ - 'label' => $childNode->getNodeType()->isOfType('Neos.Neos:Document') ? - $childNode->getProperty('title') : $childNode->getLabel(), - 'contextPath' => $childNode->getContextPath(), - 'nodeType' => $childNode->getNodeType()->getName(), - 'hasChildren' => $hasChildNodes, - 'isActive' => $this->active && ($childNode->getPath() === $this->active->getPath()), - 'isFocused' => $this->active && ($childNode->getPath() === $this->active->getPath()), - 'isCollapsed' => !$shouldLoadChildNodes, - 'isCollapsable' => $hasChildNodes - ]; - - if ($shouldLoadChildNodes) { - $result[$childNode->getName()]['children'] = - $this->build(false, $childNode, $depth - 1); - } - - if ($childNode->getNodeType()->isOfType('Neos.Neos:Document')) { - $result[$childNode->getName()]['href'] = $this->linkingService->createNodeUri( - /* $controllerContext */ - $this->controllerContext, - /* $node */ - $childNode, - /* $baseNode */ - null, - /* $format */ - null, - /* $absolute */ - true - ); - } - } - - if ($includeRoot) { - return [ - $root->getName() => [ - 'label' => $root->getNodeType()->isOfType('Neos.Neos:Document') ? - $root->getProperty('title') : $root->getLabel(), - 'icon' => 'globe', - 'contextPath' => $root->getContextPath(), - 'nodeType' => $root->getNodeType()->getName(), - 'hasChildren' => count($result), - 'isCollapsed' => false, - 'isActive' => $this->active && ($root->getPath() === $this->active->getPath()), - 'isFocused' => $this->active && ($root->getPath() === $this->active->getPath()), - 'children' => $result - ] - ]; - } - - return $result; - } - - protected function isInRootLine(Node $haystack = null, Node $needle) - { - if ($haystack === null) { - return false; - } - - return mb_strrpos($haystack->getPath(), $needle->getPath(), null, 'UTF-8') === 0; - } -}