diff --git a/DistributionPackages/Neos.NeosIo/Classes/ContentRepository/Transformations/FlattenCollectionsTransformation.php b/DistributionPackages/Neos.NeosIo/Classes/ContentRepository/Transformations/FlattenCollectionsTransformation.php index 29b009ae5..0f13c952a 100644 --- a/DistributionPackages/Neos.NeosIo/Classes/ContentRepository/Transformations/FlattenCollectionsTransformation.php +++ b/DistributionPackages/Neos.NeosIo/Classes/ContentRepository/Transformations/FlattenCollectionsTransformation.php @@ -3,34 +3,41 @@ namespace Neos\NeosIo\ContentRepository\Transformations; -use Neos\ContentRepository\Domain\Model\NodeInterface; +use Neos\ContentRepository\Domain\Factory\NodeFactory; use Neos\ContentRepository\Domain\Model\NodeData; +use Neos\ContentRepository\Domain\Model\NodeInterface; use Neos\ContentRepository\Migration\Transformations\AbstractTransformation; -use Neos\Neos\Controller\CreateContentContextTrait; +use Neos\Flow\Annotations as Flow; /** * Move content of elements with a single content collection to the parent to cleanup the content tree */ class FlattenCollectionsTransformation extends AbstractTransformation { - use CreateContentContextTrait; + /** + * @Flow\Inject + * @var NodeFactory + */ + protected $nodeFactory; public function isTransformable(NodeData $node): bool { - $numberOfChildNodes = $node->getNumberOfChildNodes('Neos.Neos:ContentCollection', $node->getWorkspace(), $node->getDimensions()); + $numberOfChildNodes = $node->getNumberOfChildNodes( + 'Neos.Neos:ContentCollection', + $node->getWorkspace(), + $node->getDimensionValues() + ); return ($numberOfChildNodes === 1); } public function execute(NodeData $node): void { - $contentContext = $this->createContentContext($node->getWorkspace()->getName(), $node->getDimensionValues()); - $parentNode = $contentContext->getNodeByIdentifier($node->getIdentifier()); + $parentNode = $this->nodeFactory->createFromNodeData($node, $this->nodeFactory->createContextMatchingNodeData($node)); if (!$parentNode) { return; } $contentCollections = $parentNode->getChildNodes('Neos.Neos:ContentCollection'); - foreach ($contentCollections as $contentCollection) { if ($contentCollection->hasChildNodes() && $contentCollection->getNodeType()->getName() === 'Neos.Neos:ContentCollection') { $this->moveChildNodesToParent($contentCollection->getChildNodes(), $parentNode); @@ -45,7 +52,17 @@ protected function moveChildNodesToParent(array $children, NodeInterface $parent { foreach ($children as $childNode) { if ($childNode instanceof NodeInterface) { - $childNode->moveInto($parentNode); + try { + $childNode->moveInto($parentNode); + } catch (\Exception $exception) { + \Neos\Flow\var_dump([ + 'contextPath' => $parentNode->getContextPath(), + 'workspace' => $parentNode->getWorkspace()->getName(), + 'dimensions' => json_encode($parentNode->getDimensions()), + 'nodetype' => $parentNode->getNodeType()->getName(), + 'exception' => $exception->getMessage(), + ], 'Could not move node ' . $parentNode->getIdentifier()); + } } } } diff --git a/DistributionPackages/Neos.NeosIo/Classes/ContentRepository/Transformations/RemoveEmptyCollectionsTransformation.php b/DistributionPackages/Neos.NeosIo/Classes/ContentRepository/Transformations/RemoveEmptyCollectionsTransformation.php index bc3d55f69..994e39e72 100644 --- a/DistributionPackages/Neos.NeosIo/Classes/ContentRepository/Transformations/RemoveEmptyCollectionsTransformation.php +++ b/DistributionPackages/Neos.NeosIo/Classes/ContentRepository/Transformations/RemoveEmptyCollectionsTransformation.php @@ -3,36 +3,51 @@ namespace Neos\NeosIo\ContentRepository\Transformations; -use Neos\ContentRepository\Domain\Model\NodeInterface; +use Neos\ContentRepository\Domain\Factory\NodeFactory; use Neos\ContentRepository\Domain\Model\NodeData; use Neos\ContentRepository\Migration\Transformations\AbstractTransformation; -use Neos\Neos\Controller\CreateContentContextTrait; +use Neos\Flow\Annotations as Flow; /** * Remove empty content collections that are leftover after the FlattenCollectionsTransformation */ class RemoveEmptyCollectionsTransformation extends AbstractTransformation { - use CreateContentContextTrait; + /** + * @Flow\Inject + * @var NodeFactory + */ + protected $nodeFactory; public function isTransformable(NodeData $node): bool { - $numberOfChildNodes = $node->getNumberOfChildNodes('Neos.Neos:ContentCollection', $node->getWorkspace(), $node->getDimensions()); - return ($numberOfChildNodes > 0); + $numberOfChildCollections = $node->getNumberOfChildNodes( + 'Neos.Neos:ContentCollection', + $node->getWorkspace(), + $node->getDimensionValues() + ); + return ($numberOfChildCollections > 0); } public function execute(NodeData $node): void { - $contentContext = $this->createContentContext($node->getWorkspace()->getName(), $node->getDimensionValues()); - $parentNode = $contentContext->getNodeByIdentifier($node->getIdentifier()); + $parentNode = $this->nodeFactory->createFromNodeData($node, $this->nodeFactory->createContextMatchingNodeData($node)); if (!$parentNode) { return; } $contentCollections = $parentNode->getChildNodes('Neos.Neos:ContentCollection'); foreach ($contentCollections as $contentCollection) { - if ($contentCollection->hasChildNodes() === false) { - $contentCollection->remove(); + if ($contentCollection->hasChildNodes() === false && $contentCollection->getNodeType()->getName() === 'Neos.Neos:ContentCollection') { + try { + $contentCollection->remove(); + } catch (\Exception $exception) { + \Neos\Flow\var_dump([ + 'dimensions' => json_encode($parentNode->getDimensions()), + 'nodetype' => $parentNode->getNodeType()->getName(), + 'exception' => $exception->getMessage(), + ], 'Could not remove node at ' . $parentNode->getContextPath()); + } } } } diff --git a/DistributionPackages/Neos.NeosIo/Migrations/ContentRepository/Version20230725110712.yaml b/DistributionPackages/Neos.NeosIo/Migrations/ContentRepository/Version20230725110712.yaml index 4757efcee..72647dd7e 100644 --- a/DistributionPackages/Neos.NeosIo/Migrations/ContentRepository/Version20230725110712.yaml +++ b/DistributionPackages/Neos.NeosIo/Migrations/ContentRepository/Version20230725110712.yaml @@ -4,7 +4,14 @@ up: - filters: - type: 'NodeType' settings: - nodeType: 'Neos.NeosIo:Stage' + nodeType: 'Neos.NeosIo:Box' + transformations: + - type: 'Neos\NeosIo\ContentRepository\Transformations\FlattenCollectionsTransformation' + - type: 'Neos\NeosIo\ContentRepository\Transformations\RemoveEmptyCollectionsTransformation' + - filters: + - type: 'NodeType' + settings: + nodeType: 'Neos.NeosIo:BadgeGrid' transformations: - type: 'Neos\NeosIo\ContentRepository\Transformations\FlattenCollectionsTransformation' - type: 'Neos\NeosIo\ContentRepository\Transformations\RemoveEmptyCollectionsTransformation' @@ -18,7 +25,7 @@ up: - filters: - type: 'NodeType' settings: - nodeType: 'Neos.NeosIo:Box' + nodeType: 'Neos.NeosIo:Stage' transformations: - type: 'Neos\NeosIo\ContentRepository\Transformations\FlattenCollectionsTransformation' - type: 'Neos\NeosIo\ContentRepository\Transformations\RemoveEmptyCollectionsTransformation' diff --git a/DistributionPackages/Neos.NeosIo/NodeTypes/Content/BadgeGrid.yaml b/DistributionPackages/Neos.NeosIo/NodeTypes/Content/BadgeGrid.yaml index d6fff2549..f7a3e7569 100644 --- a/DistributionPackages/Neos.NeosIo/NodeTypes/Content/BadgeGrid.yaml +++ b/DistributionPackages/Neos.NeosIo/NodeTypes/Content/BadgeGrid.yaml @@ -1,13 +1,11 @@ 'Neos.NeosIo:BadgeGrid': superTypes: 'Neos.Neos:Content': true - childNodes: - badges: - type: 'Neos.Neos:ContentCollection' - constraints: - nodeTypes: - '*': false - 'Neos.NeosIo:Badge': true + 'Neos.Neos:ContentCollection': true + constraints: + nodeTypes: + '*': false + 'Neos.NeosIo:Badge': true ui: label: 'Badge grid' icon: 'th-large' diff --git a/DistributionPackages/Neos.NeosIo/Resources/Private/Fusion/Content/BadgeGrid.fusion b/DistributionPackages/Neos.NeosIo/Resources/Private/Fusion/Content/BadgeGrid.fusion index f6311e778..4fa90c216 100644 --- a/DistributionPackages/Neos.NeosIo/Resources/Private/Fusion/Content/BadgeGrid.fusion +++ b/DistributionPackages/Neos.NeosIo/Resources/Private/Fusion/Content/BadgeGrid.fusion @@ -1,9 +1,7 @@ -prototype(Neos.NeosIo:BadgeGrid) < prototype(Neos.Neos:Content) { - templatePath = 'resource://Neos.NeosIo/Private/Templates/NodeTypes/BadgeGrid.html' - - attributes.class = 'g' - - badges = Neos.Neos:ContentCollection { - nodePath = 'badges' - } +prototype(Neos.NeosIo:BadgeGrid) < prototype(Neos.Neos:ContentComponent) { + renderer = afx` +