From c34456b47d544e1eef12a969472ecbe3b3fa140e Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 10 Oct 2024 20:08:41 +0200 Subject: [PATCH] TASK: Adjust to `find*` vs `get*` convention > "all operations which are slow should be named find*", vs. "all operations which operate on already-loaded data should be named get*". see https://github.com/neos/neos-development-collection/pull/5279#discussion_r1795281709 --- Neos.ContentRepository.Core/Classes/ContentRepository.php | 2 +- .../Classes/Service/WorkspaceMaintenanceService.php | 4 ++-- .../Behavior/Features/Bootstrap/ProjectedNodeTrait.php | 2 +- .../Classes/AssetUsage/AssetUsageIndexingProcessor.php | 2 +- .../AssetUsage/Service/AssetUsageIndexingService.php | 2 +- Neos.Neos/Classes/Command/WorkspaceCommandController.php | 4 ++-- .../Controller/Module/Administration/SitesController.php | 2 +- Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php | 2 +- .../Fusion/Cache/AssetChangeHandlerForCacheFlushing.php | 2 +- .../Tests/Behavior/Features/Bootstrap/RoutingTrait.php | 6 +++--- .../Classes/Controller/WorkspaceController.php | 8 ++++---- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Neos.ContentRepository.Core/Classes/ContentRepository.php b/Neos.ContentRepository.Core/Classes/ContentRepository.php index bf3b69731b2..0914e76bb88 100644 --- a/Neos.ContentRepository.Core/Classes/ContentRepository.php +++ b/Neos.ContentRepository.Core/Classes/ContentRepository.php @@ -247,7 +247,7 @@ public function findWorkspaceByName(WorkspaceName $workspaceName): ?Workspace return $this->getContentRepositoryReadModel()->findWorkspaceByName($workspaceName); } - public function getWorkspaces(): Workspaces + public function findWorkspaces(): Workspaces { return $this->getContentRepositoryReadModel()->findWorkspaces(); } diff --git a/Neos.ContentRepository.Core/Classes/Service/WorkspaceMaintenanceService.php b/Neos.ContentRepository.Core/Classes/Service/WorkspaceMaintenanceService.php index 3dd792237aa..0c2ee14feab 100644 --- a/Neos.ContentRepository.Core/Classes/Service/WorkspaceMaintenanceService.php +++ b/Neos.ContentRepository.Core/Classes/Service/WorkspaceMaintenanceService.php @@ -30,7 +30,7 @@ public function __construct( */ public function rebaseOutdatedWorkspaces(?RebaseErrorHandlingStrategy $strategy = null): Workspaces { - $outdatedWorkspaces = $this->contentRepository->getWorkspaces()->filter( + $outdatedWorkspaces = $this->contentRepository->findWorkspaces()->filter( fn (Workspace $workspace) => $workspace->status === WorkspaceStatus::OUTDATED ); /** @var Workspace $workspace */ @@ -52,7 +52,7 @@ public function rebaseOutdatedWorkspaces(?RebaseErrorHandlingStrategy $strategy public function pruneAll(): void { - foreach ($this->contentRepository->getWorkspaces() as $workspace) { + foreach ($this->contentRepository->findWorkspaces() as $workspace) { $streamName = WorkspaceEventStreamName::fromWorkspaceName($workspace->workspaceName)->getEventStreamName(); $this->eventStore->deleteStream($streamName); } diff --git a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/ProjectedNodeTrait.php b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/ProjectedNodeTrait.php index cbd7721db64..d5fde970ec4 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/ProjectedNodeTrait.php +++ b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/ProjectedNodeTrait.php @@ -81,7 +81,7 @@ public function iGetTheNodeAtPath(string $serializedNodePath): void public function iExpectANodeIdentifiedByXToExistInTheContentGraph(string $serializedNodeDiscriminator): void { $nodeDiscriminator = NodeDiscriminator::fromShorthand($serializedNodeDiscriminator); - $matchingWorkspace = $this->currentContentRepository->getWorkspaces()->find( + $matchingWorkspace = $this->currentContentRepository->findWorkspaces()->find( static fn (Workspace $workspace) => $workspace->currentContentStreamId->equals($nodeDiscriminator->contentStreamId) ); if ($matchingWorkspace === null) { diff --git a/Neos.Neos/Classes/AssetUsage/AssetUsageIndexingProcessor.php b/Neos.Neos/Classes/AssetUsage/AssetUsageIndexingProcessor.php index 9c8af9bdde6..17c8482dabb 100644 --- a/Neos.Neos/Classes/AssetUsage/AssetUsageIndexingProcessor.php +++ b/Neos.Neos/Classes/AssetUsage/AssetUsageIndexingProcessor.php @@ -27,7 +27,7 @@ public function buildIndex(ContentRepository $contentRepository, NodeTypeName $n { $variationGraph = $contentRepository->getVariationGraph(); - $allWorkspaces = $contentRepository->getWorkspaces(); + $allWorkspaces = $contentRepository->findWorkspaces(); $liveWorkspace = $contentRepository->findWorkspaceByName(WorkspaceName::forLive()); if ($liveWorkspace === null) { throw WorkspaceDoesNotExist::butWasSupposedTo(WorkspaceName::forLive()); diff --git a/Neos.Neos/Classes/AssetUsage/Service/AssetUsageIndexingService.php b/Neos.Neos/Classes/AssetUsage/Service/AssetUsageIndexingService.php index 20ad0bababe..a6c42ef5523 100644 --- a/Neos.Neos/Classes/AssetUsage/Service/AssetUsageIndexingService.php +++ b/Neos.Neos/Classes/AssetUsage/Service/AssetUsageIndexingService.php @@ -246,7 +246,7 @@ private function getWorkspaceDependents(ContentRepositoryId $contentRepositoryId while ($stack !== []) { /** @var Workspace $workspace */ $workspace = array_shift($stack); - $descendants = $contentRepository->getWorkspaces()->getDependantWorkspaces($workspace->workspaceName); + $descendants = $contentRepository->findWorkspaces()->getDependantWorkspaces($workspace->workspaceName); foreach ($descendants as $descendant) { $collectedWorkspaceNames[] = $descendant->workspaceName; $stack[] = $descendant; diff --git a/Neos.Neos/Classes/Command/WorkspaceCommandController.php b/Neos.Neos/Classes/Command/WorkspaceCommandController.php index c717dd90204..2fdd87931c2 100644 --- a/Neos.Neos/Classes/Command/WorkspaceCommandController.php +++ b/Neos.Neos/Classes/Command/WorkspaceCommandController.php @@ -376,7 +376,7 @@ public function deleteCommand(string $workspace, bool $force = false, string $co $this->quit(2); } - $dependentWorkspaces = $contentRepositoryInstance->getWorkspaces()->getDependantWorkspaces($workspaceName); + $dependentWorkspaces = $contentRepositoryInstance->findWorkspaces()->getDependantWorkspaces($workspaceName); if (!$dependentWorkspaces->isEmpty()) { $this->outputLine('Workspace "%s" cannot be deleted because the following workspaces are based on it:', [$workspaceName->value]); @@ -460,7 +460,7 @@ public function listCommand(string $contentRepository = 'default'): void { $contentRepositoryId = ContentRepositoryId::fromString($contentRepository); - $workspaces = $this->contentRepositoryRegistry->get($contentRepositoryId)->getWorkspaces(); + $workspaces = $this->contentRepositoryRegistry->get($contentRepositoryId)->findWorkspaces(); if ($workspaces->isEmpty()) { $this->outputLine('No workspaces found.'); diff --git a/Neos.Neos/Classes/Controller/Module/Administration/SitesController.php b/Neos.Neos/Classes/Controller/Module/Administration/SitesController.php index 7dabc86f97d..e124b5cd0a1 100755 --- a/Neos.Neos/Classes/Controller/Module/Administration/SitesController.php +++ b/Neos.Neos/Classes/Controller/Module/Administration/SitesController.php @@ -202,7 +202,7 @@ public function updateSiteAction(Site $site, $newSiteNodeName) ); } - foreach ($contentRepository->getWorkspaces() as $workspace) { + foreach ($contentRepository->findWorkspaces() as $workspace) { $siteNodeAggregate = $contentRepository->getContentGraph($workspace->workspaceName)->findChildNodeAggregateByName( $sitesNode->nodeAggregateId, $site->getNodeName()->toNodeName() diff --git a/Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php b/Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php index 9ab73ee61fd..e90df40aecf 100644 --- a/Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php +++ b/Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php @@ -55,7 +55,7 @@ public function removeSiteNode(SiteNodeName $siteNodeName): void ); } - foreach ($this->contentRepository->getWorkspaces() as $workspace) { + foreach ($this->contentRepository->findWorkspaces() as $workspace) { $contentGraph = $this->contentRepository->getContentGraph($workspace->workspaceName); $sitesNodeAggregate = $contentGraph->findRootNodeAggregateByType( NodeTypeNameFactory::forSites() diff --git a/Neos.Neos/Classes/Fusion/Cache/AssetChangeHandlerForCacheFlushing.php b/Neos.Neos/Classes/Fusion/Cache/AssetChangeHandlerForCacheFlushing.php index a3f93115dba..13a240c39d7 100644 --- a/Neos.Neos/Classes/Fusion/Cache/AssetChangeHandlerForCacheFlushing.php +++ b/Neos.Neos/Classes/Fusion/Cache/AssetChangeHandlerForCacheFlushing.php @@ -110,7 +110,7 @@ private function getWorkspaceNameAndChildWorkspaceNames(ContentRepository $conte $workspace = array_shift($stack); $workspaceNames[] = $workspace->workspaceName; - $stack = array_merge($stack, iterator_to_array($contentRepository->getWorkspaces()->getDependantWorkspaces($workspace->workspaceName))); + $stack = array_merge($stack, iterator_to_array($contentRepository->findWorkspaces()->getDependantWorkspaces($workspace->workspaceName))); } } $this->workspaceRuntimeCache[$contentRepository->id->value][$workspaceName->value] = $workspaceNames; diff --git a/Neos.Neos/Tests/Behavior/Features/Bootstrap/RoutingTrait.php b/Neos.Neos/Tests/Behavior/Features/Bootstrap/RoutingTrait.php index 3614993ec10..3eb2dc1a93a 100644 --- a/Neos.Neos/Tests/Behavior/Features/Bootstrap/RoutingTrait.php +++ b/Neos.Neos/Tests/Behavior/Features/Bootstrap/RoutingTrait.php @@ -186,7 +186,7 @@ public function theMatchedNodeShouldBeInContentStreamAndOriginDimension(string $ Assert::assertTrue($matchedNodeAddress->workspaceName->isLive()); Assert::assertSame($nodeAggregateId, $matchedNodeAddress->aggregateId->value); // todo useless check? - $workspace = $this->currentContentRepository->getWorkspaces()->find( + $workspace = $this->currentContentRepository->findWorkspaces()->find( fn (Workspace $potentialWorkspace) => $potentialWorkspace->currentContentStreamId->equals(ContentStreamId::fromString($contentStreamId)) ); Assert::assertSame($contentStreamId, $workspace?->currentContentStreamId->value); @@ -221,7 +221,7 @@ public function theUrlShouldMatchTheNodeInContentStreamAndDimension(string $url, Assert::assertEquals(NodeAggregateId::fromString($nodeAggregateId), $matchedNodeAddress->aggregateId, 'Expected nodeAggregateId doesn\'t match.'); // todo use workspace name instead here: - $workspace = $this->currentContentRepository->getWorkspaces()->find( + $workspace = $this->currentContentRepository->findWorkspaces()->find( fn (Workspace $potentialWorkspace) => $potentialWorkspace->currentContentStreamId->equals(ContentStreamId::fromString($contentStreamId)) ); Assert::assertEquals($workspace->workspaceName, $matchedNodeAddress->workspaceName, 'Expected workspace doesn\'t match.'); @@ -309,7 +309,7 @@ private function resolveUrl(string $nodeAggregateId, string $contentStreamId, st if ($this->requestUrl === null) { $this->iAmOnUrl('/'); } - $workspace = $this->currentContentRepository->getWorkspaces()->find( + $workspace = $this->currentContentRepository->findWorkspaces()->find( fn (Workspace $potentialWorkspace) => $potentialWorkspace->currentContentStreamId->equals(ContentStreamId::fromString($contentStreamId)) ); diff --git a/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php b/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php index d00224b7cba..8a47a321f53 100644 --- a/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php +++ b/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php @@ -134,7 +134,7 @@ public function indexAction(): void $contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId); $items = []; - $allWorkspaces = $contentRepository->getWorkspaces(); + $allWorkspaces = $contentRepository->findWorkspaces(); foreach ($allWorkspaces as $workspace) { $workspaceMetadata = $this->workspaceService->getWorkspaceMetadata($contentRepositoryId, $workspace->workspaceName); $permissions = $this->workspaceService->getWorkspacePermissionsForUser($contentRepositoryId, $workspace->workspaceName, $currentUser); @@ -350,7 +350,7 @@ public function deleteAction(WorkspaceName $workspaceName): void $this->redirect('index'); } - $dependentWorkspaces = $contentRepository->getWorkspaces()->getDependantWorkspaces($workspaceName); + $dependentWorkspaces = $contentRepository->findWorkspaces()->getDependantWorkspaces($workspaceName); if (!$dependentWorkspaces->isEmpty()) { $dependentWorkspaceTitles = []; /** @var Workspace $dependentWorkspace */ @@ -852,7 +852,7 @@ protected function renderContentChanges( ContentStreamId $contentStreamIdOfOriginalNode, ContentRepository $contentRepository, ): array { - $currentWorkspace = $contentRepository->getWorkspaces()->find( + $currentWorkspace = $contentRepository->findWorkspaces()->find( fn (Workspace $potentialWorkspace) => $potentialWorkspace->currentContentStreamId->equals($contentStreamIdOfOriginalNode) ); $originalNode = null; @@ -1036,7 +1036,7 @@ protected function prepareBaseWorkspaceOptions( ): array { $user = $this->userService->getCurrentUser(); $baseWorkspaceOptions = []; - $workspaces = $contentRepository->getWorkspaces(); + $workspaces = $contentRepository->findWorkspaces(); foreach ($workspaces as $workspace) { if ($excludedWorkspace !== null) { if ($workspace->workspaceName->equals($excludedWorkspace)) {