Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into bugfix/node-type-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
dlubitz committed Dec 23, 2024
2 parents fc2a988 + d126245 commit 1b90ed2
Show file tree
Hide file tree
Showing 9 changed files with 330 additions and 8 deletions.
73 changes: 73 additions & 0 deletions config/set/contentrepository-90.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,79 @@
// overrideNodeTypes(completeNodeTypeConfiguration: array): void
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Service\NodeTypeManager::class, 'overrideNodeTypes', '!! NodeTypeManager::createNodeType() was never meant to be used outside of testing and is removed in Neos 9.0.');

/**
* NodeData
*/
$nodeDataWarningMessage = '!! NodeData::%2$s is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here.';
// createNodeData(name: string, [nodeType: NodeType|null = null], [identifier: null|string = null], [workspace: Workspace|null = null], [dimensions: array|null = null]): NodeData
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'createNodeData', $nodeDataWarningMessage);
// createNodeDataFromTemplate(nodeTemplate: NodeTemplate, [nodeName: null|string = null], [workspace: Workspace|null = null], [dimensions: array|null = null]): NodeData
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'createNodeDataFromTemplate', $nodeDataWarningMessage);
// createShadow(path: string): NodeData
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'createShadow', $nodeDataWarningMessage);
// createSingleNodeData(name: string, [nodeType: NodeType|null = null], [identifier: null|string = null], [workspace: Workspace|null = null], [dimensions: array|null = null]): NodeData
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'createSingleNodeData', $nodeDataWarningMessage);
// getContextPath(): string
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getContextPath', $nodeDataWarningMessage);
// getDepth(): int
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getDepth', $nodeDataWarningMessage);
// getDimensions(): NodeDimension[]
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getDimensions', $nodeDataWarningMessage);
// getDimensionsHash(): string
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getDimensionsHash', $nodeDataWarningMessage);
// getDimensionValues(): array
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getDimensionValues', $nodeDataWarningMessage);
// getIdentifier(): string
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getIdentifier', $nodeDataWarningMessage);
// getIndex(): int
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getIndex', $nodeDataWarningMessage);
// getMovedTo(): NodeData
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getMovedTo', $nodeDataWarningMessage);
// getName(): string
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getName', $nodeDataWarningMessage);
// getNumberOfChildNodes(nodeTypeFilter: string, workspace: Workspace, dimensions: array): int
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getNumberOfChildNodes', $nodeDataWarningMessage);
// getParent(): NodeData|null
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getParent', $nodeDataWarningMessage);
// getParentPath(): string
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getParentPath', $nodeDataWarningMessage);
// getPath(): string
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getPath', $nodeDataWarningMessage);
// getWorkspace(): Workspace
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getWorkspace', $nodeDataWarningMessage);
// hasAccessRestrictions(): bool
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'hasAccessRestrictions', $nodeDataWarningMessage);
// isAccessible(): bool
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'isAccessible', $nodeDataWarningMessage);
// isInternal(): bool
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'isInternal', $nodeDataWarningMessage);
// isRemoved(): bool
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'isRemoved', $nodeDataWarningMessage);
// isVisible(): bool
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'isVisible', $nodeDataWarningMessage);
// matchesWorkspaceAndDimensions(workspace: Workspace, [dimensions: array|null = null]): bool
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'matchesWorkspaceAndDimensions', $nodeDataWarningMessage);
// move(targetPath: string, targetWorkspace: Workspace): NodeData|null
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'targetPath', $nodeDataWarningMessage);
// remove(): void
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'remove', $nodeDataWarningMessage);
// setDimensions(dimensionsToBeSet: array): void
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'setDimensions', $nodeDataWarningMessage);
// setIdentifier(identifier: string): void
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'setIdentifier', $nodeDataWarningMessage);
// setIndex(index: int): void
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'setIndex', $nodeDataWarningMessage);
// setMovedTo([nodeData: NodeData|null = null]): void
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'setMovedTo', $nodeDataWarningMessage);
// setPath(path: string, [recursive: bool = true]): void
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'setPath', $nodeDataWarningMessage);
// setRemoved(removed: bool): void
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'setRemoved', $nodeDataWarningMessage);
// setWorkspace([workspace: Workspace|null = null]): void
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'setWorkspace', $nodeDataWarningMessage);
// similarize(sourceNode: AbstractNodeData, [isCopy: bool = false]): void
$methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'similarize', $nodeDataWarningMessage);

/**
* Signals and Slots
* https://docs.neos.io/api/upgrade-instructions/9/signals-and-slots
Expand Down
5 changes: 4 additions & 1 deletion src/ContentRepository90/Rules/NodeSearchServiceRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ public function refactor(Node $node): ?Node
{
assert($node instanceof Node\Expr\MethodCall);

if (!$this->isObjectType($node->var, new ObjectType(\Neos\Neos\Domain\Service\NodeSearchService::class))) {
if (
!$this->isObjectType($node->var, new ObjectType(\Neos\Neos\Domain\Service\NodeSearchService::class))
&& !$this->isObjectType($node->var, new ObjectType(\Neos\Neos\Domain\Service\NodeSearchServiceInterface::class))
) {
return null;
}
if (!$this->isName($node->name, 'findByProperties')) {
Expand Down
2 changes: 1 addition & 1 deletion src/Generic/Rules/MethodCallToWarningCommentRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function refactor(Node $node): ?Node

$this->nodesToAddCollector->addNodesBeforeNode(
[
self::todoComment($methodCallToWarningComment->warningMessage)
self::todoComment(sprintf($methodCallToWarningComment->warningMessage, $methodCallToWarningComment->objectType, $methodCallToWarningComment->methodName))
],
$node
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace Neos\Rector\Test;

use Neos\ContentRepository\Domain\Model\Node;
use Neos\ContentRepository\Domain\Service\Context;

class SomeClass extends AnotherClass
{
/**
* @var \Neos\Neos\Domain\Service\NodeSearchServiceInterface
*/
private $nodeSearchServiceInterface;

public function startingPointNodeIsGiven(Node $node, Context $context)
{
$term = "term";
$searchNodeTypes = [];
$nodes = $this->nodeSearchServiceInterface->findByProperties($term, $searchNodeTypes, $context, $node);
}

public function startingPointNodeIsNotGiven(Context $context)
{
$term = "term";
$searchNodeTypes = [];
$nodes = $this->nodeSearchServiceInterface->findByProperties($term, $searchNodeTypes, $context);
}
}

-----
<?php

namespace Neos\Rector\Test;

use Neos\ContentRepository\Domain\Model\Node;
use Neos\ContentRepository\Domain\Service\Context;

class SomeClass extends AnotherClass
{
/**
* @var \Neos\Neos\Domain\Service\NodeSearchServiceInterface
*/
private $nodeSearchServiceInterface;

public function startingPointNodeIsGiven(Node $node, Context $context)
{
$term = "term";
$searchNodeTypes = [];
// TODO 9.0 migration: This could be a suitable replacement. Please check if all your requirements are still fulfilled.
$subgraph = $this->contentRepositoryRegistry->subgraphForNode($node);
$nodes = $subgraph->findDescendantNodes($node->aggregateId, \Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindDescendantNodesFilter::create(nodeTypes: \Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\NodeTypeCriteria::create(\Neos\ContentRepository\Core\NodeType\NodeTypeNames::fromStringArray($searchNodeTypes), \Neos\ContentRepository\Core\NodeType\NodeTypeNames::createEmpty()), searchTerm: $term));
}

public function startingPointNodeIsNotGiven(Context $context)
{
$term = "term";
$searchNodeTypes = [];
// TODO 9.0 migration: The replacement needs a node as starting point for the search. Please provide a node, to make this replacement working.
$node = 'we-need-a-node-here';
$subgraph = $this->contentRepositoryRegistry->subgraphForNode($node);
$nodes = $subgraph->findDescendantNodes($node->aggregateId, \Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindDescendantNodesFilter::create(nodeTypes: \Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\NodeTypeCriteria::create(\Neos\ContentRepository\Core\NodeType\NodeTypeNames::fromStringArray($searchNodeTypes), \Neos\ContentRepository\Core\NodeType\NodeTypeNames::createEmpty()), searchTerm: $term));
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class SomeClass
{
public function run(NodeLegacyStub $node)
{
$node->getNode();
return $node->getWorkspace();
}
}
Expand All @@ -20,6 +21,9 @@ class SomeClass
{
public function run(NodeLegacyStub $node)
{
// TODO 9.0 migration: !! Neos\Rector\ContentRepository90\Legacy\NodeLegacyStub::getNode() has been removed.

$node->getNode();
// TODO 9.0 migration: !! Node::getWorkspace() does not make sense anymore concept-wise. In Neos < 9, it pointed to the workspace where the node was *at home at*. Now, the closest we have here is the node identity.

return $node->getWorkspace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->ruleWithConfiguration(MethodCallToWarningCommentRector::class, [
new MethodCallToWarningComment(NodeLegacyStub::class, 'getWorkspace', '!! Node::getWorkspace() does not make sense anymore concept-wise. In Neos < 9, it pointed to the workspace where the node was *at home at*. Now, the closest we have here is the node identity.')
new MethodCallToWarningComment(NodeLegacyStub::class, 'getWorkspace', '!! Node::getWorkspace() does not make sense anymore concept-wise. In Neos < 9, it pointed to the workspace where the node was *at home at*. Now, the closest we have here is the node identity.'),
new MethodCallToWarningComment(NodeLegacyStub::class, 'getNode', '!! %%1$s::%%2$s() has been removed.'),
]);
};
Loading

0 comments on commit 1b90ed2

Please sign in to comment.