Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
declare(strict_types=1);

namespace Neos\NeosIo\ContentRepository\Transformation;

use Neos\ContentRepository\Core\CommandHandler\Commands;
use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet;
use Neos\ContentRepository\Core\Feature\NodeMove\Command\MoveNodeAggregate;
use Neos\ContentRepository\Core\Feature\NodeMove\Dto\RelationDistributionStrategy;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindChildNodesFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\SharedModel\Node\NodeName;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepository\NodeMigration\Transformation\GlobalTransformationInterface;
use Neos\ContentRepository\NodeMigration\Transformation\NodeAggregateBasedTransformationInterface;
use Neos\ContentRepository\NodeMigration\Transformation\NodeBasedTransformationInterface;
use Neos\ContentRepository\NodeMigration\Transformation\TransformationFactoryInterface;
use Neos\ContentRepository\NodeMigration\Transformation\TransformationStep;
use Neos\Neos\Domain\SubtreeTagging\NeosVisibilityConstraints;

class FlattenCollectionTransformation implements TransformationFactoryInterface
{
/**
* @param array{collectionNodeName: string} $settings
*/
public function build(
array $settings,
ContentRepository $contentRepository,
): GlobalTransformationInterface|NodeAggregateBasedTransformationInterface|NodeBasedTransformationInterface
{
return new class (
$settings['collectionNodeName'],
$contentRepository,
) implements NodeBasedTransformationInterface {
public function __construct(
private readonly string $collectionNodeName,
private readonly ContentRepository $contentRepository,
)
{
}

public function execute(
Node $node,
DimensionSpacePointSet $coveredDimensionSpacePoints,
WorkspaceName $workspaceNameForWriting
): TransformationStep
{
$subgraph = $this->contentRepository
->getContentGraph($node->workspaceName)
->getSubgraph(
$node->dimensionSpacePoint,
NeosVisibilityConstraints::excludeRemoved()
);
$collectionNode = $subgraph->findNodeByPath(
NodeName::fromString($this->collectionNodeName),
$node->aggregateId
);

if (!$collectionNode) {
return TransformationStep::createEmpty();
}

$commands = Commands::fromArray($subgraph->findChildNodes(
$collectionNode->aggregateId,
FindChildNodesFilter::create()
)->map(function (Node $childNode) use ($node, $workspaceNameForWriting) {
return MoveNodeAggregate::create(
$workspaceNameForWriting,
$node->dimensionSpacePoint,
$childNode->aggregateId,
RelationDistributionStrategy::STRATEGY_GATHER_ALL,
$node->aggregateId
);
}));

return TransformationStep::fromCommands($commands);
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Neos:
specializations:
de:
label: German

nodeMigration:
transformationFactories:
FlattenCollection: Neos\NeosIo\ContentRepository\Transformation\FlattenCollectionTransformation

Neos:
sites:
'*':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ Neos:
u: false
underline: false
strikethrough: false
sub: false
sup: false
sub: true
sup: true
del: false
p: true
h1: false
Expand Down Expand Up @@ -73,9 +73,9 @@ Neos:
u: true
underline: true
strikethrough: true
sub: false
sup: false
del: false
sub: true
sup: true
del: true
p: true
h1: true
h2: true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
comments: 'Flatten badge grid by removing intermittent collection'
migration:
- filters:
- type: 'NodeType'
settings:
nodeType: 'Neos.NeosIo:BadgeGrid'
transformations:
- type: 'FlattenCollection'
settings:
collectionNodeName: 'badges'
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
center: true
right: true
justify: true
sup: true
sub: true
Original file line number Diff line number Diff line change
@@ -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`
<div class="badge-grid g">
<Neos.Neos:ContentCollection />
</div>
`
}

This file was deleted.