Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/9.0' into bugfix/restoreLinkingS…
Browse files Browse the repository at this point in the history
…ervice
  • Loading branch information
mhsdesign committed Oct 10, 2024
2 parents b0fd72f + 276f1cb commit 881127b
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 13 deletions.
32 changes: 27 additions & 5 deletions Neos.ContentRepository.Core/Classes/ContentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
use Neos\ContentRepository\Core\Projection\ProjectionStateInterface;
use Neos\ContentRepository\Core\Projection\ProjectionStatuses;
use Neos\ContentRepository\Core\Projection\WithMarkStaleInterface;
use Neos\ContentRepository\Core\Projection\Workspace\Workspace;
use Neos\ContentRepository\Core\Projection\Workspace\WorkspaceFinder;
use Neos\ContentRepository\Core\Projection\Workspace\Workspaces;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryStatus;
use Neos\ContentRepository\Core\SharedModel\Exception\WorkspaceDoesNotExist;
Expand Down Expand Up @@ -234,11 +236,6 @@ public function resetProjectionState(string $projectionClassName): void
$projection->reset();
}

public function getNodeTypeManager(): NodeTypeManager
{
return $this->nodeTypeManager;
}

/**
* @throws WorkspaceDoesNotExist if the workspace does not exist
*/
Expand All @@ -247,6 +244,26 @@ public function getContentGraph(WorkspaceName $workspaceName): ContentGraphInter
return $this->projectionState(ContentGraphFinder::class)->getByWorkspaceName($workspaceName);
}

/**
* Returns the workspace with the given name, or NULL if it does not exist in this content repository
*/
public function findWorkspaceByName(WorkspaceName $workspaceName): ?Workspace
{
return $this->getWorkspaceFinder()->findOneByName($workspaceName);
}

/**
* Returns all workspaces of this content repository. To limit the set, {@see Workspaces::find()} and {@see Workspaces::filter()} can be used
* as well as {@see Workspaces::getBaseWorkspaces()} and {@see Workspaces::getDependantWorkspaces()}.
*/
public function findWorkspaces(): Workspaces
{
return $this->getWorkspaceFinder()->findAll();
}

/**
* @deprecated with 9.0.0-beta14 please use {@see ContentRepository::findWorkspaces()} and {@see ContentRepository::findWorkspaceByName()} instead.
*/
public function getWorkspaceFinder(): WorkspaceFinder
{
return $this->projectionState(WorkspaceFinder::class);
Expand All @@ -257,6 +274,11 @@ public function getContentStreamFinder(): ContentStreamFinder
return $this->projectionState(ContentStreamFinder::class);
}

public function getNodeTypeManager(): NodeTypeManager
{
return $this->nodeTypeManager;
}

public function getVariationGraph(): InterDimensionalVariationGraph
{
return $this->variationGraph;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,9 @@ public function isPublicWorkspace(): bool
{
return $this->baseWorkspaceName === null && $this->workspaceOwner === null;
}

public function isRootWorkspace(): bool
{
return $this->baseWorkspaceName !== null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceTitle;

/**
* Workspace Finder
* The legacy Workspace Finder
*
* @deprecated with 9.0.0-beta14 please use {@see ContentRepository::findWorkspaces()} and {@see ContentRepository::findWorkspaceByName()} instead.
* @api
*/
final class WorkspaceFinder implements ProjectionStateInterface
Expand All @@ -36,7 +37,9 @@ public function __construct(
) {
}


/**
* @deprecated with 9.0.0-beta14 please use {@see ContentRepository::findWorkspaceByName()} instead
*/
public function findOneByName(WorkspaceName $name): ?Workspace
{
$workspace = $this->workspaceRuntimeCache->getWorkspaceByName($name);
Expand All @@ -63,6 +66,15 @@ public function findOneByName(WorkspaceName $name): ?Workspace
return $workspace;
}

/**
* @deprecated with 9.0.0-beta14 discouraged. You should just operate on workspace names instead.
* To still archive the functionality please use {@see ContentRepository::findWorkspaces()} instead and filter the result:
*
* $this->contentRepository->getWorkspaces()->find(
* fn (Workspace $workspace) => $workspace->currentContentStreamId->equals($contentStreamId)
* )
*
*/
public function findOneByCurrentContentStreamId(
ContentStreamId $contentStreamId
): ?Workspace {
Expand Down Expand Up @@ -93,6 +105,7 @@ public function findOneByCurrentContentStreamId(
/**
* @return array<string,Workspace>
* @throws DBALException
* @deprecated with 9.0.0-beta14 please use {@see ContentRepository::findWorkspaces()} and {@see Workspaces::getDependantWorkspaces()} instead.
*/
public function findByBaseWorkspace(WorkspaceName $baseWorkspace): array
{
Expand All @@ -116,6 +129,10 @@ public function findByBaseWorkspace(WorkspaceName $baseWorkspace): array
return $result;
}

/**
* @deprecated with 9.0.0-beta14 owners/collaborators should be assigned to workspaces outside the Content Repository core
* For Neos.Neos please use {@see \Neos\Neos\Domain\Service\WorkspaceService::getPersonalWorkspaceForUser()}
*/
public function findOneByWorkspaceOwner(string $owner): ?Workspace
{
$workspaceRow = $this->dbal->executeQuery(
Expand All @@ -135,6 +152,9 @@ public function findOneByWorkspaceOwner(string $owner): ?Workspace
return $this->createWorkspaceFromDatabaseRow($workspaceRow);
}

/**
* @deprecated with 9.0.0-beta14 please use {@see ContentRepository::findWorkspaces()} instead
*/
public function findAll(): Workspaces
{
$result = [];
Expand All @@ -154,6 +174,12 @@ public function findAll(): Workspaces
}

/**
* @deprecated with 9.0.0-beta14 please use {@see ContentRepository::findWorkspaces()} instead and filter the result:
*
* $this->contentRepository->getWorkspaces()->filter(
* fn (Workspace $workspace) => $workspace->status === WorkspaceStatus::OUTDATED
* )
*
* @return array<string,Workspace>
* @throws \Doctrine\DBAL\Driver\Exception
* @throws DBALException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ public function getBaseWorkspaces(WorkspaceName $workspaceName): Workspaces
return Workspaces::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<int,Workspace>
*/
Expand All @@ -100,8 +110,44 @@ public function getIterator(): \Traversable
yield from array_values($this->workspaces);
}

/**
* @param \Closure(Workspace): bool $callback
*/
public function filter(\Closure $callback): self
{
return new self(array_filter($this->workspaces, $callback));
}

/**
* @param \Closure(Workspace): bool $callback
*/
public function find(\Closure $callback): ?Workspace
{
foreach ($this->workspaces as $workspace) {
if ($callback($workspace)) {
return $workspace;
}
}
return null;
}

/**
* @template T
* @param \Closure(Workspace): T $callback
* @return list<T>
*/
public function map(\Closure $callback): array
{
return array_map($callback, array_values($this->workspaces));
}

public function count(): int
{
return count($this->workspaces);
}

public function isEmpty(): bool
{
return $this->workspaces === [];
}
}
2 changes: 1 addition & 1 deletion Neos.Neos/Documentation/References/CommandReference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ commands that may be available, use::

./flow help

The following reference was automatically generated from code on 2024-10-09
The following reference was automatically generated from code on 2024-10-10


.. _`Neos Command Reference: NEOS.FLOW`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
FluidAdaptor ViewHelper Reference
#################################

This reference was automatically generated from code on 2024-10-09
This reference was automatically generated from code on 2024-10-10


.. _`FluidAdaptor ViewHelper Reference: f:debug`:
Expand Down
2 changes: 1 addition & 1 deletion Neos.Neos/Documentation/References/ViewHelpers/Form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Form ViewHelper Reference
#########################

This reference was automatically generated from code on 2024-10-09
This reference was automatically generated from code on 2024-10-10


.. _`Form ViewHelper Reference: neos.form:form`:
Expand Down
2 changes: 1 addition & 1 deletion Neos.Neos/Documentation/References/ViewHelpers/Media.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Media ViewHelper Reference
##########################

This reference was automatically generated from code on 2024-10-09
This reference was automatically generated from code on 2024-10-10


.. _`Media ViewHelper Reference: neos.media:fileTypeIcon`:
Expand Down
2 changes: 1 addition & 1 deletion Neos.Neos/Documentation/References/ViewHelpers/Neos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Neos ViewHelper Reference
#########################

This reference was automatically generated from code on 2024-10-09
This reference was automatically generated from code on 2024-10-10


.. _`Neos ViewHelper Reference: neos:backend.authenticationProviderLabel`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
TYPO3 Fluid ViewHelper Reference
################################

This reference was automatically generated from code on 2024-10-09
This reference was automatically generated from code on 2024-10-10


.. _`TYPO3 Fluid ViewHelper Reference: f:alias`:
Expand Down

0 comments on commit 881127b

Please sign in to comment.