From bae8a3d3f0e607851ebc032918106e4860f5a4bc Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Sun, 24 Sep 2023 22:38:18 +0200 Subject: [PATCH] TASK: Remove `ContentRepositoryRegistryProvider` and use "classic" _protected var pattern in trait Introducing the pattern with the additional `ContentRepositoryRegistryProvider` makes things just more complex and less obvious. While not perfectly "clean" we instead import in the `NodeTypeWithFallbackProvider` trait the `ContentRepositoryRegistry` via $_contentRepositoryRegistry. This pattern is already used across the codebase. --- .../Privilege/Node/NodePrivilegeContext.php | 5 +++-- .../Utility/ContentRepositoryRegistryProvider.php | 15 --------------- .../Controller/Backend/ContentController.php | 5 +++-- .../Controller/Frontend/NodeController.php | 5 +++-- .../Domain/Service/NodeSiteResolvingService.php | 5 +++-- .../Classes/Domain/Service/SiteNodeUtility.php | 5 +++-- .../ContentRepositoryIntegrationService.php | 5 +++-- Neos.Neos/Classes/Fusion/Helper/NodeHelper.php | 5 +++-- .../Classes/Routing/Cache/RouteCacheFlusher.php | 5 +++-- .../Utility/NodeTypeWithFallbackProvider.php | 8 +++++--- Neos.Neos/Classes/View/FusionView.php | 5 +++-- .../Backend/DocumentBreadcrumbPathViewHelper.php | 5 +++-- .../Classes/ViewHelpers/Link/NodeViewHelper.php | 5 +++-- 13 files changed, 38 insertions(+), 40 deletions(-) delete mode 100644 Neos.ContentRepositoryRegistry/Classes/Utility/ContentRepositoryRegistryProvider.php diff --git a/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php b/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php index 1609220ca3d..06c39096c5a 100644 --- a/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php +++ b/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php @@ -17,7 +17,6 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindAncestorNodesFilter; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; -use Neos\ContentRepositoryRegistry\Utility\ContentRepositoryRegistryProvider; use Neos\Flow\Annotations as Flow; use Neos\Flow\Security\Context as SecurityContext; use Neos\Neos\Utility\NodeTypeWithFallbackProvider; @@ -27,9 +26,11 @@ */ class NodePrivilegeContext { - use ContentRepositoryRegistryProvider; use NodeTypeWithFallbackProvider; + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; + /** * @Flow\Inject * @var SecurityContext diff --git a/Neos.ContentRepositoryRegistry/Classes/Utility/ContentRepositoryRegistryProvider.php b/Neos.ContentRepositoryRegistry/Classes/Utility/ContentRepositoryRegistryProvider.php deleted file mode 100644 index 432291627ad..00000000000 --- a/Neos.ContentRepositoryRegistry/Classes/Utility/ContentRepositoryRegistryProvider.php +++ /dev/null @@ -1,15 +0,0 @@ -contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId)->getNodeTypeManager(); + $nodeTypeManager = $this->_contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId)->getNodeTypeManager(); return $nodeTypeManager->hasNodeType($node->nodeTypeName) ? $nodeTypeManager->getNodeType($node->nodeTypeName) diff --git a/Neos.Neos/Classes/View/FusionView.php b/Neos.Neos/Classes/View/FusionView.php index 0183572e541..0596705c97e 100644 --- a/Neos.Neos/Classes/View/FusionView.php +++ b/Neos.Neos/Classes/View/FusionView.php @@ -16,7 +16,6 @@ use GuzzleHttp\Psr7\Message; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; -use Neos\ContentRepositoryRegistry\Utility\ContentRepositoryRegistryProvider; use Neos\Flow\Annotations as Flow; use Neos\Flow\Mvc\View\AbstractView; use Neos\Flow\Security\Context; @@ -40,9 +39,11 @@ class FusionView extends AbstractView { use FusionViewI18nTrait; - use ContentRepositoryRegistryProvider; use NodeTypeWithFallbackProvider; + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; + /** * @Flow\Inject * @var SiteNodeUtility diff --git a/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php b/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php index 0e07cef55a4..3757f98c837 100644 --- a/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php +++ b/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php @@ -15,7 +15,6 @@ namespace Neos\Neos\ViewHelpers\Backend; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; -use Neos\ContentRepositoryRegistry\Utility\ContentRepositoryRegistryProvider; use Neos\Flow\Annotations as Flow; use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper; use Neos\Neos\Domain\Service\NodeTypeNameFactory; @@ -26,9 +25,11 @@ */ class DocumentBreadcrumbPathViewHelper extends AbstractViewHelper { - use ContentRepositoryRegistryProvider; use NodeTypeWithFallbackProvider; + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; + /** * @var boolean */ diff --git a/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php b/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php index f5ab5cfa033..4b80aad2419 100644 --- a/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php +++ b/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php @@ -18,7 +18,6 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\Projection\ContentGraph\NodePath; -use Neos\ContentRepositoryRegistry\Utility\ContentRepositoryRegistryProvider; use Neos\Neos\Domain\Service\NodeTypeNameFactory; use Neos\Neos\FrontendRouting\NodeAddress; use Neos\Neos\FrontendRouting\NodeAddressFactory; @@ -127,9 +126,11 @@ class NodeViewHelper extends AbstractTagBasedViewHelper { use FusionContextTrait; - use ContentRepositoryRegistryProvider; use NodeTypeWithFallbackProvider; + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; + /** * @var string */