From db7861f683f7e308f8515d4be955ccc57dc04fd1 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 10 Oct 2024 09:26:10 +0200 Subject: [PATCH] TASK: Fixup after merge of asset usage refactoring Initially the exporter got passed the `WorkspaceFinder` and had to fetch the live workspace themselves to determine the content stream id. Temporarily we then passed the $targetContentStreamId, but some places now need the workspace name as well. Thus we pass the whole $targetWorkspace. Also a utility `getDependantWorkspaces` was introduced to simplify the `filter` usage from the caller. --- .../SharedModel/Workspace/Workspaces.php | 20 +++++++++++++++++++ .../Bootstrap/CrImportExportTrait.php | 2 +- .../src/ExportService.php | 8 ++++---- .../src/ExportServiceFactory.php | 5 ++--- .../src/Processors/AssetExportProcessor.php | 11 +++------- .../src/Processors/EventExportProcessor.php | 6 +++--- .../AssetUsageIndexingProcessor.php | 7 +++---- .../Service/AssetUsageIndexingService.php | 14 ++++++------- .../Classes/Command/CrCommandController.php | 17 ++++++++-------- .../Command/WorkspaceCommandController.php | 4 +--- .../AssetChangeHandlerForCacheFlushing.php | 8 +++++--- .../Features/Bootstrap/RoutingTrait.php | 13 +++++++++--- .../Bootstrap/WorkspaceServiceTrait.php | 6 ------ .../Controller/WorkspaceController.php | 9 ++------- 14 files changed, 69 insertions(+), 61 deletions(-) diff --git a/Neos.ContentRepository.Core/Classes/SharedModel/Workspace/Workspaces.php b/Neos.ContentRepository.Core/Classes/SharedModel/Workspace/Workspaces.php index 671f8ab1ed4..236b2170f83 100644 --- a/Neos.ContentRepository.Core/Classes/SharedModel/Workspace/Workspaces.php +++ b/Neos.ContentRepository.Core/Classes/SharedModel/Workspace/Workspaces.php @@ -87,6 +87,16 @@ public function getBaseWorkspaces(WorkspaceName $workspaceName): Workspaces return self::fromArray($baseWorkspaces); } + /** + * Get all dependent workspaces (if they are included in this result set). + */ + public function getDependantWorkspaces(WorkspaceName $workspaceName): Workspaces + { + return $this->filter( + static fn (Workspace $potentiallyDependentWorkspace) => $potentiallyDependentWorkspace->baseWorkspaceName?->equals($workspaceName) ?? false + ); + } + /** * @return \Traversable */ @@ -116,6 +126,16 @@ public function find(\Closure $callback): ?Workspace return null; } + /** + * @template T + * @param \Closure(Workspace): T $callback + * @return list + */ + public function map(\Closure $callback): array + { + return array_map($callback, array_values($this->workspaces)); + } + public function count(): int { return count($this->workspaces); diff --git a/Neos.ContentRepository.Export/Tests/Behavior/Features/Bootstrap/CrImportExportTrait.php b/Neos.ContentRepository.Export/Tests/Behavior/Features/Bootstrap/CrImportExportTrait.php index 16b8155fe8f..0aa571b20ea 100644 --- a/Neos.ContentRepository.Export/Tests/Behavior/Features/Bootstrap/CrImportExportTrait.php +++ b/Neos.ContentRepository.Export/Tests/Behavior/Features/Bootstrap/CrImportExportTrait.php @@ -65,7 +65,7 @@ public function __construct(private readonly Filesystem $filesystem) public function build(ContentRepositoryServiceFactoryDependencies $serviceFactoryDependencies): EventExportProcessor { return new EventExportProcessor( $this->filesystem, - $serviceFactoryDependencies->contentRepository->findWorkspaceByName(WorkspaceName::forLive())->currentContentStreamId, + $serviceFactoryDependencies->contentRepository->findWorkspaceByName(WorkspaceName::forLive()), $serviceFactoryDependencies->eventStore ); } diff --git a/Neos.ContentRepository.Export/src/ExportService.php b/Neos.ContentRepository.Export/src/ExportService.php index 97dcff6bc87..6f7f6491531 100644 --- a/Neos.ContentRepository.Export/src/ExportService.php +++ b/Neos.ContentRepository.Export/src/ExportService.php @@ -5,8 +5,8 @@ use League\Flysystem\Filesystem; use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceInterface; -use Neos\ContentRepository\Core\Projection\Workspace\WorkspaceFinder; use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId; +use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace; use Neos\ContentRepository\Export\Processors\AssetExportProcessor; use Neos\ContentRepository\Export\Processors\EventExportProcessor; use Neos\EventStore\EventStoreInterface; @@ -22,7 +22,7 @@ class ExportService implements ContentRepositoryServiceInterface public function __construct( private readonly ContentRepositoryId $contentRepositoryId, private readonly Filesystem $filesystem, - private readonly WorkspaceFinder $workspaceFinder, + private readonly Workspace $targetWorkspace, private readonly AssetRepository $assetRepository, private readonly AssetUsageService $assetUsageService, private readonly EventStoreInterface $eventStore, @@ -35,14 +35,14 @@ public function runAllProcessors(\Closure $outputLineFn, bool $verbose = false): $processors = [ 'Exporting events' => new EventExportProcessor( $this->filesystem, - $this->workspaceFinder, + $this->targetWorkspace, $this->eventStore ), 'Exporting assets' => new AssetExportProcessor( $this->contentRepositoryId, $this->filesystem, $this->assetRepository, - $this->workspaceFinder, + $this->targetWorkspace, $this->assetUsageService ) ]; diff --git a/Neos.ContentRepository.Export/src/ExportServiceFactory.php b/Neos.ContentRepository.Export/src/ExportServiceFactory.php index 945177a7c60..e36d50be983 100644 --- a/Neos.ContentRepository.Export/src/ExportServiceFactory.php +++ b/Neos.ContentRepository.Export/src/ExportServiceFactory.php @@ -7,7 +7,6 @@ use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceFactoryDependencies; use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceFactoryInterface; use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace; -use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; use Neos\Media\Domain\Repository\AssetRepository; use Neos\Neos\AssetUsage\AssetUsageService; @@ -20,7 +19,7 @@ class ExportServiceFactory implements ContentRepositoryServiceFactoryInterface public function __construct( private readonly Filesystem $filesystem, - private readonly ContentStreamId $targetContentStreamId, + private readonly Workspace $targetWorkspace, private readonly AssetRepository $assetRepository, private readonly AssetUsageService $assetUsageService, ) { @@ -31,7 +30,7 @@ public function build(ContentRepositoryServiceFactoryDependencies $serviceFactor return new ExportService( $serviceFactoryDependencies->contentRepositoryId, $this->filesystem, - $this->targetContentStreamId, + $this->targetWorkspace, $this->assetRepository, $this->assetUsageService, $serviceFactoryDependencies->eventStore, diff --git a/Neos.ContentRepository.Export/src/Processors/AssetExportProcessor.php b/Neos.ContentRepository.Export/src/Processors/AssetExportProcessor.php index ff2fa71dab9..3bceb6dc77f 100644 --- a/Neos.ContentRepository.Export/src/Processors/AssetExportProcessor.php +++ b/Neos.ContentRepository.Export/src/Processors/AssetExportProcessor.php @@ -3,9 +3,8 @@ namespace Neos\ContentRepository\Export\Processors; use League\Flysystem\Filesystem; -use Neos\ContentRepository\Core\Projection\Workspace\WorkspaceFinder; use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId; -use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; +use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace; use Neos\ContentRepository\Export\Asset\ValueObject\SerializedAsset; use Neos\ContentRepository\Export\Asset\ValueObject\SerializedImageVariant; use Neos\ContentRepository\Export\ProcessorInterface; @@ -33,7 +32,7 @@ public function __construct( private readonly ContentRepositoryId $contentRepositoryId, private readonly Filesystem $files, private readonly AssetRepository $assetRepository, - private readonly WorkspaceFinder $workspaceFinder, + private readonly Workspace $targetWorkspace, private readonly AssetUsageService $assetUsageService, ) {} @@ -45,11 +44,7 @@ public function onMessage(\Closure $callback): void public function run(): ProcessorResult { - $liveWorkspace = $this->workspaceFinder->findOneByName(WorkspaceName::forLive()); - if ($liveWorkspace === null) { - return ProcessorResult::error('Failed to find live workspace'); - } - $assetFilter = AssetUsageFilter::create()->withWorkspaceName($liveWorkspace->workspaceName)->groupByAsset(); + $assetFilter = AssetUsageFilter::create()->withWorkspaceName($this->targetWorkspace->workspaceName)->groupByAsset(); $numberOfExportedAssets = 0; $numberOfExportedImageVariants = 0; diff --git a/Neos.ContentRepository.Export/src/Processors/EventExportProcessor.php b/Neos.ContentRepository.Export/src/Processors/EventExportProcessor.php index d12fc5a1d08..b7d0b486188 100644 --- a/Neos.ContentRepository.Export/src/Processors/EventExportProcessor.php +++ b/Neos.ContentRepository.Export/src/Processors/EventExportProcessor.php @@ -6,7 +6,7 @@ use League\Flysystem\FilesystemException; use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceInterface; use Neos\ContentRepository\Core\Feature\ContentStreamEventStreamName; -use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; +use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace; use Neos\ContentRepository\Export\Event\ValueObject\ExportedEvent; use Neos\ContentRepository\Export\ProcessorInterface; use Neos\ContentRepository\Export\ProcessorResult; @@ -23,7 +23,7 @@ final class EventExportProcessor implements ProcessorInterface, ContentRepositor public function __construct( private readonly Filesystem $files, - private readonly ContentStreamId $targetContentStreamId, + private readonly Workspace $targetWorkspace, private readonly EventStoreInterface $eventStore, ) { } @@ -35,7 +35,7 @@ public function onMessage(\Closure $callback): void public function run(): ProcessorResult { - $streamName = ContentStreamEventStreamName::fromContentStreamId($this->targetContentStreamId)->getEventStreamName(); + $streamName = ContentStreamEventStreamName::fromContentStreamId($this->targetWorkspace->currentContentStreamId)->getEventStreamName(); $eventStream = $this->eventStore->load($streamName); $eventFileResource = fopen('php://temp/maxmemory:5242880', 'rb+'); diff --git a/Neos.Neos/Classes/AssetUsage/AssetUsageIndexingProcessor.php b/Neos.Neos/Classes/AssetUsage/AssetUsageIndexingProcessor.php index 9a05c7260c8..9c8af9bdde6 100644 --- a/Neos.Neos/Classes/AssetUsage/AssetUsageIndexingProcessor.php +++ b/Neos.Neos/Classes/AssetUsage/AssetUsageIndexingProcessor.php @@ -9,7 +9,6 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindChildNodesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; -use Neos\ContentRepository\Core\SharedModel\Exception\NodeAggregateCurrentlyDoesNotExist; use Neos\ContentRepository\Core\SharedModel\Exception\WorkspaceDoesNotExist; use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; use Neos\Neos\AssetUsage\Service\AssetUsageIndexingService; @@ -28,8 +27,8 @@ public function buildIndex(ContentRepository $contentRepository, NodeTypeName $n { $variationGraph = $contentRepository->getVariationGraph(); - $workspaceFinder = $contentRepository->getWorkspaceFinder(); - $liveWorkspace = $workspaceFinder->findOneByName(WorkspaceName::forLive()); + $allWorkspaces = $contentRepository->getWorkspaces(); + $liveWorkspace = $contentRepository->findWorkspaceByName(WorkspaceName::forLive()); if ($liveWorkspace === null) { throw WorkspaceDoesNotExist::butWasSupposedTo(WorkspaceName::forLive()); } @@ -73,7 +72,7 @@ public function buildIndex(ContentRepository $contentRepository, NodeTypeName $n } } - array_push($workspaces, ...array_values($workspaceFinder->findByBaseWorkspace($workspace->workspaceName))); + array_push($workspaces, ...iterator_to_array($allWorkspaces->getDependantWorkspaces($workspace->workspaceName))); } } diff --git a/Neos.Neos/Classes/AssetUsage/Service/AssetUsageIndexingService.php b/Neos.Neos/Classes/AssetUsage/Service/AssetUsageIndexingService.php index 56c8aa7bff4..20ad0bababe 100644 --- a/Neos.Neos/Classes/AssetUsage/Service/AssetUsageIndexingService.php +++ b/Neos.Neos/Classes/AssetUsage/Service/AssetUsageIndexingService.php @@ -9,10 +9,10 @@ use Neos\ContentRepository\Core\NodeType\NodeType; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\Projection\ContentGraph\PropertyCollection; -use Neos\ContentRepository\Core\Projection\Workspace\Workspace; use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId; use Neos\ContentRepository\Core\SharedModel\Exception\WorkspaceDoesNotExist; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; +use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace; use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Persistence\Doctrine\PersistenceManager; @@ -201,8 +201,8 @@ public function pruneIndex(ContentRepositoryId $contentRepositoryId): void private function getWorkspaceBasesAndWorkspace(ContentRepositoryId $contentRepositoryId, WorkspaceName $workspaceName): array { if (!isset($this->workspaceBases[$contentRepositoryId->value][$workspaceName->value])) { - $workspaceFinder = $this->contentRepositoryRegistry->get($contentRepositoryId)->getWorkspaceFinder(); - $workspace = $workspaceFinder->findOneByName($workspaceName); + $contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId); + $workspace = $contentRepository->findWorkspaceByName($workspaceName); if ($workspace === null) { throw WorkspaceDoesNotExist::butWasSupposedTo($workspaceName); } @@ -214,7 +214,7 @@ private function getWorkspaceBasesAndWorkspace(ContentRepositoryId $contentRepos while ($stack !== []) { $workspace = array_shift($stack); if ($workspace->baseWorkspaceName) { - $ancestor = $workspaceFinder->findOneByName($workspace->baseWorkspaceName); + $ancestor = $contentRepository->findWorkspaceByName($workspace->baseWorkspaceName); if ($ancestor === null) { throw WorkspaceDoesNotExist::butWasSupposedTo($workspace->baseWorkspaceName); } @@ -235,8 +235,8 @@ private function getWorkspaceBasesAndWorkspace(ContentRepositoryId $contentRepos private function getWorkspaceDependents(ContentRepositoryId $contentRepositoryId, WorkspaceName $workspaceName): array { if (!isset($this->workspaceDependents[$contentRepositoryId->value][$workspaceName->value])) { - $workspaceFinder = $this->contentRepositoryRegistry->get($contentRepositoryId)->getWorkspaceFinder(); - $workspace = $workspaceFinder->findOneByName($workspaceName); + $contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId); + $workspace = $contentRepository->findWorkspaceByName($workspaceName); if ($workspace === null) { throw WorkspaceDoesNotExist::butWasSupposedTo($workspaceName); } @@ -246,7 +246,7 @@ private function getWorkspaceDependents(ContentRepositoryId $contentRepositoryId while ($stack !== []) { /** @var Workspace $workspace */ $workspace = array_shift($stack); - $descendants = $workspaceFinder->findByBaseWorkspace($workspace->workspaceName); + $descendants = $contentRepository->getWorkspaces()->getDependantWorkspaces($workspace->workspaceName); foreach ($descendants as $descendant) { $collectedWorkspaceNames[] = $descendant->workspaceName; $stack[] = $descendant; diff --git a/Neos.Neos/Classes/Command/CrCommandController.php b/Neos.Neos/Classes/Command/CrCommandController.php index ba7bb7e9b27..23a75318b7c 100644 --- a/Neos.Neos/Classes/Command/CrCommandController.php +++ b/Neos.Neos/Classes/Command/CrCommandController.php @@ -9,13 +9,13 @@ use Neos\ContentRepository\Core\Projection\CatchUpOptions; use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; +use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; use Neos\ContentRepository\Export\ExportService; use Neos\ContentRepository\Export\ExportServiceFactory; use Neos\ContentRepository\Export\ImportService; use Neos\ContentRepository\Export\ImportServiceFactory; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\ContentRepositoryRegistry\Service\ProjectionReplayServiceFactory; -use Neos\Flow\Annotations as Flow; use Neos\Flow\Cli\CommandController; use Neos\Flow\Persistence\PersistenceManagerInterface; use Neos\Flow\ResourceManagement\ResourceManager; @@ -26,12 +26,6 @@ class CrCommandController extends CommandController { - /** - * @var array - */ - #[Flow\InjectConfiguration(package: 'Neos.Flow')] - protected array $flowSettings; - public function __construct( private readonly AssetRepository $assetRepository, private readonly ResourceRepository $resourceRepository, @@ -55,16 +49,21 @@ public function __construct( public function exportCommand(string $path, string $contentRepository = 'default', bool $verbose = false): void { $contentRepositoryId = ContentRepositoryId::fromString($contentRepository); - $contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId); + $contentRepositoryInstance = $this->contentRepositoryRegistry->get($contentRepositoryId); Files::createDirectoryRecursively($path); $filesystem = new Filesystem(new LocalFilesystemAdapter($path)); + $liveWorkspace = $contentRepositoryInstance->findWorkspaceByName(WorkspaceName::forLive()); + if ($liveWorkspace === null) { + throw new \RuntimeException('Failed to find live workspace', 1716652280); + } + $exportService = $this->contentRepositoryRegistry->buildService( $contentRepositoryId, new ExportServiceFactory( $filesystem, - $contentRepository->getWorkspaceFinder(), + $liveWorkspace, $this->assetRepository, $this->assetUsageService, ) diff --git a/Neos.Neos/Classes/Command/WorkspaceCommandController.php b/Neos.Neos/Classes/Command/WorkspaceCommandController.php index a1e6851f040..c717dd90204 100644 --- a/Neos.Neos/Classes/Command/WorkspaceCommandController.php +++ b/Neos.Neos/Classes/Command/WorkspaceCommandController.php @@ -376,9 +376,7 @@ public function deleteCommand(string $workspace, bool $force = false, string $co $this->quit(2); } - $dependentWorkspaces = $contentRepositoryInstance->getWorkspaces()->filter( - static fn (Workspace $potentiallyDependentWorkspace) => $potentiallyDependentWorkspace->baseWorkspaceName?->equals($workspaceName) ?? false - ); + $dependentWorkspaces = $contentRepositoryInstance->getWorkspaces()->getDependantWorkspaces($workspaceName); if (!$dependentWorkspaces->isEmpty()) { $this->outputLine('Workspace "%s" cannot be deleted because the following workspaces are based on it:', [$workspaceName->value]); diff --git a/Neos.Neos/Classes/Fusion/Cache/AssetChangeHandlerForCacheFlushing.php b/Neos.Neos/Classes/Fusion/Cache/AssetChangeHandlerForCacheFlushing.php index da3a7c05c55..a3f93115dba 100644 --- a/Neos.Neos/Classes/Fusion/Cache/AssetChangeHandlerForCacheFlushing.php +++ b/Neos.Neos/Classes/Fusion/Cache/AssetChangeHandlerForCacheFlushing.php @@ -9,7 +9,9 @@ use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateIds; +use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace; use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; +use Neos\ContentRepository\Core\SharedModel\Workspace\Workspaces; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Persistence\PersistenceManagerInterface; use Neos\Media\Domain\Model\AssetInterface; @@ -19,7 +21,7 @@ class AssetChangeHandlerForCacheFlushing { - /** @var array > */ + /** @var array> */ private array $workspaceRuntimeCache = []; public function __construct( @@ -100,7 +102,7 @@ private function getWorkspaceNameAndChildWorkspaceNames(ContentRepository $conte { if (!isset($this->workspaceRuntimeCache[$contentRepository->id->value][$workspaceName->value])) { $workspaceNames = []; - $workspace = $contentRepository->getWorkspaceFinder()->findOneByName($workspaceName); + $workspace = $contentRepository->findWorkspaceByName($workspaceName); if ($workspace !== null) { $stack[] = $workspace; @@ -108,7 +110,7 @@ private function getWorkspaceNameAndChildWorkspaceNames(ContentRepository $conte $workspace = array_shift($stack); $workspaceNames[] = $workspace->workspaceName; - $stack = array_merge($stack, array_values($contentRepository->getWorkspaceFinder()->findByBaseWorkspace($workspace->workspaceName))); + $stack = array_merge($stack, iterator_to_array($contentRepository->getWorkspaces()->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 b3a8a1b399e..3614993ec10 100644 --- a/Neos.Neos/Tests/Behavior/Features/Bootstrap/RoutingTrait.php +++ b/Neos.Neos/Tests/Behavior/Features/Bootstrap/RoutingTrait.php @@ -21,6 +21,7 @@ use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; +use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace; use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\CRTestSuiteRuntimeVariables; use Neos\Flow\Configuration\ConfigurationManager; use Neos\Flow\Http\ServerRequestAttributes; @@ -185,7 +186,9 @@ public function theMatchedNodeShouldBeInContentStreamAndOriginDimension(string $ Assert::assertTrue($matchedNodeAddress->workspaceName->isLive()); Assert::assertSame($nodeAggregateId, $matchedNodeAddress->aggregateId->value); // todo useless check? - $workspace = $this->currentContentRepository->getWorkspaceFinder()->findOneByCurrentContentStreamId(ContentStreamId::fromString($contentStreamId)); + $workspace = $this->currentContentRepository->getWorkspaces()->find( + fn (Workspace $potentialWorkspace) => $potentialWorkspace->currentContentStreamId->equals(ContentStreamId::fromString($contentStreamId)) + ); Assert::assertSame($contentStreamId, $workspace?->currentContentStreamId->value); Assert::assertSame( DimensionSpacePoint::fromJsonString($dimensionSpacePoint), @@ -218,7 +221,9 @@ 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->getWorkspaceFinder()->findOneByCurrentContentStreamId(ContentStreamId::fromString($contentStreamId)); + $workspace = $this->currentContentRepository->getWorkspaces()->find( + fn (Workspace $potentialWorkspace) => $potentialWorkspace->currentContentStreamId->equals(ContentStreamId::fromString($contentStreamId)) + ); Assert::assertEquals($workspace->workspaceName, $matchedNodeAddress->workspaceName, 'Expected workspace doesn\'t match.'); Assert::assertTrue($matchedNodeAddress->dimensionSpacePoint->equals(DimensionSpacePoint::fromJsonString($dimensionSpacePoint)), 'Expected dimensionSpacePoint doesn\'t match.'); } @@ -304,7 +309,9 @@ private function resolveUrl(string $nodeAggregateId, string $contentStreamId, st if ($this->requestUrl === null) { $this->iAmOnUrl('/'); } - $workspace = $this->currentContentRepository->getWorkspaceFinder()->findOneByCurrentContentStreamId(ContentStreamId::fromString($contentStreamId)); + $workspace = $this->currentContentRepository->getWorkspaces()->find( + fn (Workspace $potentialWorkspace) => $potentialWorkspace->currentContentStreamId->equals(ContentStreamId::fromString($contentStreamId)) + ); $nodeAddress = NodeAddress::create( $this->currentContentRepository->id, diff --git a/Neos.Neos/Tests/Behavior/Features/Bootstrap/WorkspaceServiceTrait.php b/Neos.Neos/Tests/Behavior/Features/Bootstrap/WorkspaceServiceTrait.php index 0570d6ee3b9..167c09ff269 100644 --- a/Neos.Neos/Tests/Behavior/Features/Bootstrap/WorkspaceServiceTrait.php +++ b/Neos.Neos/Tests/Behavior/Features/Bootstrap/WorkspaceServiceTrait.php @@ -17,9 +17,7 @@ use Neos\ContentRepository\Core\Feature\WorkspaceCreation\Command\CreateRootWorkspace; use Neos\ContentRepository\Core\Feature\WorkspaceCreation\Command\CreateWorkspace; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; -use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceDescription as DeprecatedWorkspaceDescription; use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; -use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceTitle as DeprecatedWorkspaceTitle; use Neos\Neos\Domain\Model\UserId; use Neos\Neos\Domain\Model\WorkspaceDescription; use Neos\Neos\Domain\Model\WorkspaceRole; @@ -98,8 +96,6 @@ public function aRootWorkspaceExistsWithoutMetadata(string $workspaceName): void { $this->currentContentRepository->handle(CreateRootWorkspace::create( WorkspaceName::fromString($workspaceName), - DeprecatedWorkspaceTitle::fromString($workspaceName), - DeprecatedWorkspaceDescription::fromString(''), ContentStreamId::create(), )); } @@ -112,8 +108,6 @@ public function aWorkspaceWithBaseWorkspaceExistsWithoutMetadata(string $workspa $this->currentContentRepository->handle(CreateWorkspace::create( WorkspaceName::fromString($workspaceName), WorkspaceName::fromString($baseWorkspaceName), - DeprecatedWorkspaceTitle::fromString($workspaceName), - DeprecatedWorkspaceDescription::fromString(''), ContentStreamId::create(), )); } diff --git a/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php b/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php index 9196557d23e..d00224b7cba 100644 --- a/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php +++ b/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php @@ -141,9 +141,6 @@ public function indexAction(): void if (!$permissions->read) { continue; } - $hasDependantWorkspaces = (bool)$allWorkspaces->find( - static fn (Workspace $potentiallyDependentWorkspace) => $potentiallyDependentWorkspace->baseWorkspaceName?->equals($workspace->workspaceName) ?? false - ); $items[] = new WorkspaceListItem( name: $workspace->workspaceName->value, classification: $workspaceMetadata->classification->name, @@ -151,7 +148,7 @@ classification: $workspaceMetadata->classification->name, description: $workspaceMetadata->description->value, baseWorkspaceName: $workspace->baseWorkspaceName?->value, pendingChanges: $this->computePendingChanges($workspace, $contentRepository), - hasDependantWorkspaces: $hasDependantWorkspaces, + hasDependantWorkspaces: !$allWorkspaces->getDependantWorkspaces($workspace->workspaceName)->isEmpty(), permissions: $permissions, ); } @@ -353,9 +350,7 @@ public function deleteAction(WorkspaceName $workspaceName): void $this->redirect('index'); } - $dependentWorkspaces = $contentRepository->getWorkspaces()->filter( - static fn (Workspace $potentiallyDependentWorkspace) => $potentiallyDependentWorkspace->baseWorkspaceName?->equals($workspaceName) ?? false - ); + $dependentWorkspaces = $contentRepository->getWorkspaces()->getDependantWorkspaces($workspaceName); if (!$dependentWorkspaces->isEmpty()) { $dependentWorkspaceTitles = []; /** @var Workspace $dependentWorkspace */