Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/flow-annotati…
Browse files Browse the repository at this point in the history
…ons-to-attributes
  • Loading branch information
dlubitz committed Sep 30, 2023
2 parents 2162175 + 618a7fd commit 7e44f4a
Show file tree
Hide file tree
Showing 107 changed files with 3,603 additions and 142 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: build

on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'

jobs:
test:
name: "Test (PHP ${{ matrix.php-versions }})"

strategy:
fail-fast: false
matrix:
php-versions: ['8.1', '8.2']

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
path: ${{ env.FLOW_FOLDER }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, json, zlib, iconv, intl, pdo_sqlite
ini-values: date.timezone="Africa/Tunis", opcache.fast_shutdown=0, apc.enable_cli=on

- name: Install
run: composer install

- name: Run Tests
run: composer test
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,8 @@ git diff -- Neos.Fusion.Afx/ > ../Libraries/neos/rector/scripts/afx-eel-position
git restore -- Neos.Fusion.Afx/
```

## Generating docs

```bash
composer run generate-docs
```
12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@
}
},
"scripts": {
"generate-docs": "rule-doc-generator generate src/Rules --output-file docs/rules_overview.md",
"generate-docs": "rule-doc-generator generate src/ContentRepository90/Rules src/Generic/Rules",
"tests": "phpunit tests"
},
"require": {
"rector/rector": "^0.14.2"
"rector/rector": "0.15.24",
"phpstan/phpstan": "1.10.11",
"symfony/yaml": "*",
"neos/utility-arrays": "*"
},
"require-dev": {
"symplify/rule-doc-generator": "^11.1",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.5",
"webmozart/assert": "^1.11",
"symplify/rule-doc-generator": "^11.1"
}
}
86 changes: 78 additions & 8 deletions config/sets/contentrepository-90.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
use Neos\Rector\ContentRepository90\Rules\ContextFactoryToLegacyContextStubRector;
use Neos\Rector\ContentRepository90\Rules\ContextGetFirstLevelNodeCacheRector;
use Neos\Rector\ContentRepository90\Rules\ContextGetRootNodeRector;
use Neos\Rector\ContentRepository90\Rules\FusionCachingNodeInEntryIdentifierRector;
use Neos\Rector\ContentRepository90\Rules\FusionContextCurrentSiteRector;
use Neos\Rector\ContentRepository90\Rules\FusionContextInBackendRector;
use Neos\Rector\ContentRepository90\Rules\FusionContextLiveRector;
use Neos\Rector\ContentRepository90\Rules\FusionNodeAggregateIdentifierRector;
use Neos\Rector\ContentRepository90\Rules\FusionNodeDepthRector;
use Neos\Rector\ContentRepository90\Rules\FusionNodeHiddenInIndexRector;
use Neos\Rector\ContentRepository90\Rules\FusionNodeIdentifierRector;
use Neos\Rector\ContentRepository90\Rules\FusionNodeParentRector;
use Neos\Rector\ContentRepository90\Rules\FusionNodePathRector;
use Neos\Rector\ContentRepository90\Rules\InjectContentRepositoryRegistryIfNeededRector;
Expand All @@ -25,17 +29,22 @@
use Neos\Rector\ContentRepository90\Rules\NodeGetPathRector;
use Neos\Rector\ContentRepository90\Rules\NodeIsHiddenInIndexRector;
use Neos\Rector\ContentRepository90\Rules\NodeIsHiddenRector;
use Neos\Rector\ContentRepository90\Rules\WorkspaceRepositoryCountByNameRector;
use Neos\Rector\ContentRepository90\Rules\YamlDimensionConfigRector;
use Neos\Rector\Generic\Rules\FusionNodePropertyPathToWarningCommentRector;
use Neos\Rector\Generic\Rules\MethodCallToWarningCommentRector;
use Neos\Rector\Generic\Rules\RemoveDuplicateCommentRector;
use Neos\Rector\Generic\Rules\RemoveInjectionsRector;
use Neos\Rector\Generic\Rules\ToStringToMethodCallOrPropertyFetchRector;
use Neos\Rector\Generic\ValueObject\FusionNodePropertyPathToWarningComment;
use Neos\Rector\Generic\ValueObject\MethodCallToWarningComment;
use Neos\Rector\Generic\ValueObject\RemoveInjection;
use Neos\Rector\Generic\ValueObject\RemoveParentClass;
use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\Transform\Rector\MethodCall\MethodCallToPropertyFetchRector;
use Rector\Transform\ValueObject\MethodCallToPropertyFetch;
use Neos\Rector\ContentRepository90\Rules\WorkspaceGetNameRector;
use Neos\Rector\ContentRepository90\Rules\NodeGetIdentifierRector;

return static function (RectorConfig $rectorConfig): void {
// Register FusionFileProcessor. All Fusion Rectors will be auto-registered at this processor.
Expand All @@ -45,6 +54,7 @@
->autowire()
->autoconfigure();
$services->set(\Neos\Rector\Core\FusionProcessing\FusionFileProcessor::class);
$services->set(\Neos\Rector\Core\YamlProcessing\YamlFileProcessor::class);
$rectorConfig->disableParallel(); // parallel does not work for non-PHP-Files, so we need to disable it - see https://github.com/rectorphp/rector-src/pull/2597#issuecomment-1190120688


Expand All @@ -59,7 +69,9 @@
'Neos\ContentRepository\Domain\Model\NodeType' => \Neos\ContentRepository\Core\NodeType\NodeType::class,
'Neos\ContentRepository\Domain\Service\NodeTypeManager' => \Neos\ContentRepository\Core\NodeType\NodeTypeManager::class,

'Neos\ContentRepository\Utility' => \Neos\ContentRepositoryRegistry\Utility::class
'Neos\ContentRepository\Utility' => \Neos\ContentRepositoryRegistry\Utility::class,

'Neos\ContentRepository\Domain\Model\Workspace' => \Neos\ContentRepository\Core\Projection\Workspace\Workspace::class,
]);


Expand Down Expand Up @@ -126,14 +138,15 @@
// - NodeAddress + LOG (WARNING)
// getDepth
$rectorConfig->rule(NodeGetDepthRector::class);
// Fusion: .depth -> Neos.NodeInfo.depth(node)
// Fusion: .depth -> Neos.Node.depth(node)
$rectorConfig->rule(FusionNodeDepthRector::class);
// setWorkspace -> internal
$methodCallToWarningComments[] = new MethodCallToWarningComment(Node::class, 'setWorkspace', '!! Node::setWorkspace() was always internal, and the workspace system has been fundamentally changed with the new CR. Try to rewrite your code around Content Streams.');
// getWorkspace
$methodCallToWarningComments[] = new MethodCallToWarningComment(Node::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.');
// getIdentifier
$methodCallToPropertyFetches[] = new MethodCallToPropertyFetch(Node::class, 'getIdentifier', 'nodeAggregateId');
$rectorConfig->rule(NodeGetIdentifierRector::class);
$rectorConfig->rule(FusionNodeIdentifierRector::class);
// setIndex -> internal
$methodCallToWarningComments[] = new MethodCallToWarningComment(Node::class, 'setIndex', '!! Node::setIndex() was always internal. To reorder nodes, use the "MoveNodeAggregate" command');
// getIndex
Expand Down Expand Up @@ -190,7 +203,7 @@
// getContentStreamIdentifier() -> threw exception in <= Neos 8.0 - so nobody could have used this
// getNodeAggregateIdentifier()
$methodCallToPropertyFetches[] = new MethodCallToPropertyFetch(Node::class, 'getNodeAggregateIdentifier', 'nodeAggregateId');
// TODO: Fusion
$rectorConfig->rule(rectorClass: FusionNodeAggregateIdentifierRector::class);
// getNodeTypeName()
$methodCallToPropertyFetches[] = new MethodCallToPropertyFetch(Node::class, 'getNodeTypeName', 'nodeTypeName');
// getNodeType() ** (included/compatible in old NodeInterface)
Expand Down Expand Up @@ -251,17 +264,18 @@
*/
// ContentContext::getCurrentSite
// TODO: PHP
$rectorConfig->rule(FusionContextCurrentSiteRector::class);
// TODO: Fusion
// ContentContext::getCurrentDomain
// TODO: PHP
// TODO: Fusion
// ContentContext::getCurrentSiteNode
// TODO: PHP
// TODO: Fusion
// ContentContext::isLive -> Neos.Ui.NodeInfo.isLive(...) (TODO - should this be part of Neos.Ui or Neos Namespace?)
// ContentContext::isLive -> Neos.Node.isLive(...)
// TODO: PHP
$rectorConfig->rule(FusionContextLiveRector::class);
// ContentContext::isInBackend -> Neos.Ui.NodeInfo.inBackend(...) (TODO - should this be part of Neos.Ui or Neos Namespace?)
// ContentContext::isInBackend -> Neos.Node.inBackend(...)
// TODO: PHP
$rectorConfig->rule(FusionContextInBackendRector::class);
// ContentContext::getCurrentRenderingMode
Expand All @@ -282,6 +296,29 @@
// NodeFactory::reset
$rectorConfig->rule(NodeFactoryResetRector::class);

/**
* Neos\ContentRepository\Domain\Repository\WorkspaceRepository
*/
$rectorConfig->rule(WorkspaceRepositoryCountByNameRector::class);

/**
* Neos\ContentRepository\Domain\Model\Workspace
*/
$rectorConfig->rule(WorkspaceGetNameRector::class);

/**
* SPECIAL rules
*/
$rectorConfig->rule(FusionCachingNodeInEntryIdentifierRector::class);
$rectorConfig->ruleWithConfiguration(\Neos\Rector\Generic\Rules\RemoveParentClassRector::class, [
new RemoveParentClass(
parentClassName: Neos\ContentRepository\Migration\Transformations\AbstractTransformation::class,
comment: '// TODO 9.0 migration: You need to convert your AbstractTransformation to an implementation of Neos\ContentRepository\NodeMigration\Transformation\TransformationFactoryInterface'
)
]);

$rectorConfig->rule(YamlDimensionConfigRector::class);

/**
* CLEAN UP / END GLOBAL RULES
*/
Expand All @@ -293,10 +330,43 @@
$rectorConfig->ruleWithConfiguration(RemoveInjectionsRector::class, [
new RemoveInjection(\Neos\ContentRepository\Domain\Service\ContextFactoryInterface::class),
new RemoveInjection(\Neos\ContentRepository\Domain\Service\ContentDimensionCombinator::class),
new RemoveInjection(\Neos\ContentRepository\Domain\Factory\NodeFactory::class)
new RemoveInjection(\Neos\ContentRepository\Domain\Factory\NodeFactory::class),
new RemoveInjection(\Neos\ContentRepository\Domain\Repository\WorkspaceRepository::class)
]);

// Should run LAST - as other rules above might create $this->contentRepositoryRegistry calls.
$rectorConfig->rule(InjectContentRepositoryRegistryIfNeededRector::class);
// TODO: does not fully seem to work.$rectorConfig->rule(RemoveDuplicateCommentRector::class);

$rectorConfig->ruleWithConfiguration(ToStringToMethodCallOrPropertyFetchRector::class, [
\Neos\ContentRepository\Core\Dimension\ContentDimensionId::class => 'value',
\Neos\ContentRepository\Core\Dimension\ContentDimensionValue::class => 'value',
\Neos\ContentRepository\Core\Dimension\ContentDimensionValueSpecializationDepth::class => 'value',
\Neos\ContentRepository\Core\Factory\ContentRepositoryId::class => 'value',
\Neos\ContentRepository\Core\Feature\ContentStreamEventStreamName::class => 'value',
\Neos\ContentRepository\Core\Infrastructure\Property\PropertyType::class => 'value',
\Neos\ContentRepository\Core\NodeType\NodeType::class => 'name',
\Neos\ContentRepository\Core\NodeType\NodeTypeName::class => 'value',
\Neos\ContentRepository\Core\Projection\ContentGraph\NodePath::class => 'value',
\Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId::class => 'value',
\Neos\ContentRepository\Core\SharedModel\Node\NodeName::class => 'value',
\Neos\ContentRepository\Core\SharedModel\Node\PropertyName::class => 'value',
\Neos\ContentRepository\Core\SharedModel\Node\ReferenceName::class => 'value',
\Neos\ContentRepository\Core\SharedModel\User\UserId::class => 'value',
\Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId::class => 'value',
\Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceDescription::class => 'value',
\Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName::class => 'value',
\Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceTitle::class => 'value',
\Neos\ContentRepository\Core\Projection\ContentGraph\NodeTypeConstraints::class => 'toFilterString()',
\Neos\ContentRepository\Core\Projection\ContentGraph\NodeTypeConstraintsWithSubNodeTypes::class => 'toFilterString()',
\Neos\ContentRepository\Core\DimensionSpace\AbstractDimensionSpacePoint::class => 'toJson()',
\Neos\ContentRepository\Core\DimensionSpace\ContentSubgraphVariationWeight::class => 'toJson()',
\Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet::class => 'toJson()',
\Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePointSet::class => 'toJson()',
\Neos\ContentRepository\Core\Feature\NodeMove\Dto\ParentNodeMoveDestination::class => 'toJson()',
\Neos\ContentRepository\Core\Feature\NodeMove\Dto\SucceedingSiblingNodeMoveDestination::class => 'toJson()',
\Neos\ContentRepository\Core\Projection\ContentGraph\CoverageByOrigin::class => 'toJson()',
\Neos\ContentRepository\Core\Projection\ContentGraph\OriginByCoverage::class => 'toJson()',
\Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateIds::class => 'toJson()',
]);
};
2 changes: 1 addition & 1 deletion docs/architecture_2022_09_16_FusionRefactorings.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Problem Description

We want to refactor Eel expressions like `node.context.inBackend` or `site.context.inBackend` towards
`Neos.Ui.NodeInfo.inBackend(node)` and `Neos.Ui.NodeInfo.inBackend(site)` respectively.
`Neos.Node.inBackend(node)` and `Neos.Node.inBackend(site)` respectively.

This must work BOTH in Eel expressions inside Fusion, and inside AFX blocks.

Expand Down
Loading

0 comments on commit 7e44f4a

Please sign in to comment.