Skip to content

Commit

Permalink
TASK: Adjust to changes in NodeType
Browse files Browse the repository at this point in the history
Adjusts to changes to fix task
neos/neos-development-collection#4515
  • Loading branch information
kitsunet committed Sep 17, 2023
1 parent 7a6c923 commit 893446c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
17 changes: 10 additions & 7 deletions Classes/Domain/Model/Changes/AbstractStructuralChange.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,17 @@ protected function findChildNodes(Node $node): Nodes
protected function isNodeTypeAllowedAsChildNode(Node $node, NodeType $nodeType): bool
{
$subgraph = $this->contentRepositoryRegistry->subgraphForNode($node);
if (NodeInfoHelper::isAutoCreated($node, $subgraph)) {
$parentNode = $subgraph->findParentNode($node->nodeAggregateId);
return !$parentNode || $parentNode->nodeType->allowsGrandchildNodeType(
$node->nodeName->value,
$nodeType
);
} else {
$contentRepository = $this->contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId);
$nodeTypeManager = $contentRepository->getNodeTypeManager();
if (!$node->classification->isTethered()) {
return $node->nodeType->allowsChildNodeType($nodeType);
}

$parentNode = $subgraph->findParentNode($node->nodeAggregateId);
return !$parentNode || $nodeTypeManager->allowsGrandchildNodeType(
$parentNode->nodeType,
$node->nodeName,
$nodeType
);
}
}
20 changes: 2 additions & 18 deletions Classes/Fusion/Helper/NodeInfoHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* source code.
*/

use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\CountAncestorNodesFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindChildNodesFilter;
Expand Down Expand Up @@ -53,12 +54,6 @@ class NodeInfoHelper implements ProtectedContextAwareInterface
*/
protected $contentRepositoryRegistry;

/**
* @Flow\Inject
* @var EntityToIdentityConverter
*/
protected $entityToIdentityConverter;

/**
* @Flow\Inject
* @var PersistenceManagerInterface
Expand Down Expand Up @@ -236,7 +231,7 @@ protected function getBasicNodeInformation(Node $node): array
'identifier' => $node->nodeAggregateId->jsonSerialize(),
'nodeType' => $node->nodeType->getName(),
'label' => $node->getLabel(),
'isAutoCreated' => self::isAutoCreated($node, $subgraph),
'isAutoCreated' => $node->classification->isTethered(),
// TODO: depth is expensive to calculate; maybe let's get rid of this?
'depth' => $subgraph->countAncestorNodes(
$node->nodeAggregateId,
Expand All @@ -251,17 +246,6 @@ protected function getBasicNodeInformation(Node $node): array
];
}

public static function isAutoCreated(Node $node, ContentSubgraphInterface $subgraph): bool
{
$parent = $subgraph->findParentNode($node->nodeAggregateId);
if ($parent) {
if (array_key_exists($node->nodeName->value, $parent->nodeType->getAutoCreatedChildNodes())) {
return true;
}
}
return false;
}

/**
* Get information for all children of the given parent node.
*
Expand Down

0 comments on commit 893446c

Please sign in to comment.