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` +
+ +
+ ` } diff --git a/DistributionPackages/Neos.NeosIo/Resources/Private/Fusion/Content/SemanticSection.fusion b/DistributionPackages/Neos.NeosIo/Resources/Private/Fusion/Content/SemanticSection.fusion index 786e76247..c3734b91b 100644 --- a/DistributionPackages/Neos.NeosIo/Resources/Private/Fusion/Content/SemanticSection.fusion +++ b/DistributionPackages/Neos.NeosIo/Resources/Private/Fusion/Content/SemanticSection.fusion @@ -2,7 +2,7 @@ prototype(Neos.NeosIo:SemanticSection) < prototype(Neos.Neos:ContentComponent) { isLast = ${iterator.isLast} renderer = afx` -
+

diff --git a/DistributionPackages/Neos.NeosIo/Resources/Private/Fusion/Overrides/Image.fusion b/DistributionPackages/Neos.NeosIo/Resources/Private/Fusion/Overrides/Image.fusion index ab32e3d17..bfd4b2021 100644 --- a/DistributionPackages/Neos.NeosIo/Resources/Private/Fusion/Overrides/Image.fusion +++ b/DistributionPackages/Neos.NeosIo/Resources/Private/Fusion/Overrides/Image.fusion @@ -12,7 +12,9 @@ prototype(Neos.NodeTypes:Image) < prototype(Neos.Neos:ContentComponent) { } image = ${q(node).property('image')} - imageClassName = Neos.Fusion:DataStructure { + className = Neos.Fusion:DataStructure { + main = 'neos-nodetypes-image' + alignment = ${'neos-alignment-' + q(node).property('alignment')} alignment.@if.isSet = ${q(node).property('alignment')} @@ -54,22 +56,38 @@ prototype(Neos.NodeTypes:Image) < prototype(Neos.Neos:ContentComponent) { renderer.@context.image = Neos.Fusion:Case { default { condition = ${props.image} - renderer = Neos.Neos:ImageTag { - asset = ${props.image} - title = ${props.title} - maximumHeight = ${props.maximumHeight} - maximumWidth = ${props.maximumWidth} - allowUpScaling = ${props.allowUpScaling} - allowCropping = ${props.allowCropping} - width = ${props.width} - height = ${props.height} - async = true - attributes.alt = ${props.alternativeText} - attributes.loading = ${props.loading} - attributes.style = Neos.Fusion:Join { - maxHeight = ${'max-height: ' + props.maximumHeight + 'px;'} - maxHeight.@if.set = ${props.maximumHeight} + renderer = Neos.Fusion:Component { + @apply.props = ${props} + + thumbnail = ${Neos.Seo.Image.createThumbnail( + props.image, + null, + props.width, + props.maximumWidth, + props.height, + props.maximumHeight, + props.allowCropping, + props.allowUpScaling, + true + )} + + renderer.@process.debug = Neos.Fusion:Debug.Console { + value = ${props} } + + renderer = afx` + {props.alternativeText} + + + ` } } fallback { @@ -87,8 +105,8 @@ prototype(Neos.NodeTypes:Image) < prototype(Neos.Neos:ContentComponent) { } renderer = afx` -