Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/9.0' into task/add-workspace-con…
Browse files Browse the repository at this point in the history
…tentstream-mapping-to-contentgraph
  • Loading branch information
mhsdesign committed Oct 9, 2024
2 parents 468c80d + 5d31a15 commit 4ea3bbe
Show file tree
Hide file tree
Showing 82 changed files with 5,047 additions and 1,403 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ jobs:
touch ${{ github.workspace }}/Data/DebugDatabaseDumps/keep
./flow package:list --loading-order
FLOW_CONTEXT=Testing/Behat ./flow doctrine:migrate --quiet
cd Packages/Neos
# composer test:behavioral
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,9 @@ public function findNodeAggregateById(
public function findParentNodeAggregates(
NodeAggregateId $childNodeAggregateId
): NodeAggregates {
$queryBuilder = $this->nodeQueryBuilder->buildBasicNodeAggregateQuery()
->innerJoin('n', $this->nodeQueryBuilder->tableNames->hierarchyRelation(), 'ch', 'ch.parentnodeanchor = n.relationanchorpoint')
->innerJoin('ch', $this->nodeQueryBuilder->tableNames->node(), 'cn', 'cn.relationanchorpoint = ch.childnodeanchor')
->andWhere('ch.contentstreamid = :contentStreamId')
$queryBuilder = $this->nodeQueryBuilder->buildParentNodeAggregateQuery()
->innerJoin('h', $this->nodeQueryBuilder->tableNames->node(), 'cn', 'cn.relationanchorpoint = h.childnodeanchor')
->andWhere('h.contentstreamid = :contentStreamId')
->andWhere('cn.nodeaggregateid = :nodeAggregateId')
->setParameters([
'nodeAggregateId' => $childNodeAggregateId->value,
Expand Down
12 changes: 10 additions & 2 deletions Neos.ContentGraph.DoctrineDbalAdapter/src/NodeQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@ public function buildChildNodeAggregateQuery(NodeAggregateId $parentNodeAggregat
return $this->createQueryBuilder()
->select('cn.*, ch.contentstreamid, ch.subtreetags, cdsp.dimensionspacepoint AS covereddimensionspacepoint')
->from($this->tableNames->node(), 'pn')
->innerJoin('pn', $this->tableNames->hierarchyRelation(), 'ph', 'ph.childnodeanchor = pn.relationanchorpoint')
->innerJoin('pn', $this->tableNames->hierarchyRelation(), 'ch', 'ch.parentnodeanchor = pn.relationanchorpoint')
->innerJoin('ch', $this->tableNames->dimensionSpacePoints(), 'cdsp', 'cdsp.hash = ch.dimensionspacepointhash')
->innerJoin('ch', $this->tableNames->node(), 'cn', 'cn.relationanchorpoint = ch.childnodeanchor')
->where('pn.nodeaggregateid = :parentNodeAggregateId')
->andWhere('ph.contentstreamid = :contentStreamId')
->andWhere('ch.contentstreamid = :contentStreamId')
->orderBy('ch.position')
->setParameters([
Expand All @@ -70,6 +68,16 @@ public function buildChildNodeAggregateQuery(NodeAggregateId $parentNodeAggregat
]);
}

public function buildParentNodeAggregateQuery(): QueryBuilder
{
return $this->createQueryBuilder()
->select('n.*, h.contentstreamid, h.subtreetags, dsp.dimensionspacepoint AS covereddimensionspacepoint')
->from($this->tableNames->node(), 'n')
->innerJoin('n', $this->tableNames->hierarchyRelation(), 'h', 'h.parentnodeanchor = n.relationanchorpoint')
->innerJoin('h', $this->tableNames->dimensionSpacePoints(), 'dsp', 'dsp.hash = h.dimensionspacepointhash')
->where('h.contentstreamid = :contentStreamId');
}

public function buildFindRootNodeAggregatesQuery(ContentStreamId $contentStreamId, FindRootNodeAggregatesFilter $filter): QueryBuilder
{
$queryBuilder = $this->buildBasicNodeAggregateQuery()
Expand Down
17 changes: 10 additions & 7 deletions Neos.ContentRepository.Export/src/ExportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@

use League\Flysystem\Filesystem;
use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceInterface;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\Projection\Workspace\WorkspaceFinder;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Export\Processors\AssetExportProcessor;
use Neos\ContentRepository\Export\Processors\EventExportProcessor;
use Neos\EventStore\EventStoreInterface;
use Neos\Media\Domain\Repository\AssetRepository;
use Neos\Neos\AssetUsage\Projection\AssetUsageFinder;
use Neos\Neos\AssetUsage\AssetUsageService;

/**
* @internal
Expand All @@ -19,10 +20,11 @@ class ExportService implements ContentRepositoryServiceInterface
{

public function __construct(
private readonly ContentRepositoryId $contentRepositoryId,
private readonly Filesystem $filesystem,
private readonly ContentStreamId $targetContentStreamId,
private readonly WorkspaceFinder $workspaceFinder,
private readonly AssetRepository $assetRepository,
private readonly AssetUsageFinder $assetUsageFinder,
private readonly AssetUsageService $assetUsageService,
private readonly EventStoreInterface $eventStore,
) {
}
Expand All @@ -33,14 +35,15 @@ public function runAllProcessors(\Closure $outputLineFn, bool $verbose = false):
$processors = [
'Exporting events' => new EventExportProcessor(
$this->filesystem,
$this->targetContentStreamId,
$this->workspaceFinder,
$this->eventStore
),
'Exporting assets' => new AssetExportProcessor(
$this->contentRepositoryId,
$this->filesystem,
$this->assetRepository,
$this->targetContentStreamId,
$this->assetUsageFinder
$this->workspaceFinder,
$this->assetUsageService
)
];

Expand Down
7 changes: 4 additions & 3 deletions Neos.ContentRepository.Export/src/ExportServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\Media\Domain\Repository\AssetRepository;
use Neos\Neos\AssetUsage\Projection\AssetUsageFinder;
use Neos\Neos\AssetUsage\AssetUsageService;

/**
* @internal
Expand All @@ -22,17 +22,18 @@ public function __construct(
private readonly Filesystem $filesystem,
private readonly ContentStreamId $targetContentStreamId,
private readonly AssetRepository $assetRepository,
private readonly AssetUsageFinder $assetUsageFinder,
private readonly AssetUsageService $assetUsageService,
) {
}

public function build(ContentRepositoryServiceFactoryDependencies $serviceFactoryDependencies): ExportService
{
return new ExportService(
$serviceFactoryDependencies->contentRepositoryId,
$this->filesystem,
$this->targetContentStreamId,
$this->assetRepository,
$this->assetUsageFinder,
$this->assetUsageService,
$serviceFactoryDependencies->eventStore,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace Neos\ContentRepository\Export\Processors;

use League\Flysystem\Filesystem;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\Projection\Workspace\WorkspaceFinder;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepository\Export\Asset\ValueObject\SerializedAsset;
use Neos\ContentRepository\Export\Asset\ValueObject\SerializedImageVariant;
use Neos\ContentRepository\Export\ProcessorInterface;
Expand All @@ -14,8 +16,8 @@
use Neos\Media\Domain\Model\AssetVariantInterface;
use Neos\Media\Domain\Model\ImageVariant;
use Neos\Media\Domain\Repository\AssetRepository;
use Neos\Neos\AssetUsage\AssetUsageService;
use Neos\Neos\AssetUsage\Dto\AssetUsageFilter;
use Neos\Neos\AssetUsage\Projection\AssetUsageFinder;

/**
* Processor that exports all assets and resources used in the Neos live workspace to the file system
Expand All @@ -28,10 +30,11 @@ final class AssetExportProcessor implements ProcessorInterface
private array $callbacks = [];

public function __construct(
private readonly ContentRepositoryId $contentRepositoryId,
private readonly Filesystem $files,
private readonly AssetRepository $assetRepository,
private readonly ContentStreamId $targetContentStreamId,
private readonly AssetUsageFinder $assetUsageFinder,
private readonly WorkspaceFinder $workspaceFinder,
private readonly AssetUsageService $assetUsageService,
) {}

public function onMessage(\Closure $callback): void
Expand All @@ -42,13 +45,17 @@ public function onMessage(\Closure $callback): void

public function run(): ProcessorResult
{
$assetFilter = AssetUsageFilter::create()->withContentStream($this->targetContentStreamId)->groupByAsset();
$liveWorkspace = $this->workspaceFinder->findOneByName(WorkspaceName::forLive());
if ($liveWorkspace === null) {
return ProcessorResult::error('Failed to find live workspace');
}
$assetFilter = AssetUsageFilter::create()->withWorkspaceName($liveWorkspace->workspaceName)->groupByAsset();

$numberOfExportedAssets = 0;
$numberOfExportedImageVariants = 0;
$numberOfErrors = 0;

foreach ($this->assetUsageFinder->findByFilter($assetFilter) as $assetUsage) {
foreach ($this->assetUsageService->findByFilter($this->contentRepositoryId, $assetFilter) as $assetUsage) {
/** @var Asset|null $asset */
$asset = $this->assetRepository->findByIdentifier($assetUsage->assetId);
if ($asset === null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
use Neos\EventStore\Model\EventStream\VirtualStreamName;
use Neos\Neos\Domain\Model\WorkspaceClassification;
use Neos\Neos\Domain\Model\WorkspaceRole;
use Neos\Neos\Domain\Model\WorkspaceSubjectType;
use Neos\Neos\Domain\Model\WorkspaceRoleSubjectType;

/**
* Content Repository service to perform migrations of events.
Expand Down Expand Up @@ -616,23 +616,23 @@ public function migrateWorkspaceMetadataToWorkspaceService(\Closure $outputFn):
$this->connection->insert('neos_neos_workspace_role', [
'content_repository_id' => $this->contentRepositoryId->value,
'workspace_name' => $workspaceName->value,
'subject_type' => WorkspaceSubjectType::GROUP->value,
'subject_type' => WorkspaceRoleSubjectType::GROUP->value,
'subject' => 'Neos.Neos:LivePublisher',
'role' => WorkspaceRole::COLLABORATOR->value,
]);
} elseif ($isInternalWorkspace) {
$this->connection->insert('neos_neos_workspace_role', [
'content_repository_id' => $this->contentRepositoryId->value,
'workspace_name' => $workspaceName->value,
'subject_type' => WorkspaceSubjectType::GROUP->value,
'subject_type' => WorkspaceRoleSubjectType::GROUP->value,
'subject' => 'Neos.Neos:AbstractEditor',
'role' => WorkspaceRole::COLLABORATOR->value,
]);
} elseif ($isPrivateWorkspace) {
$this->connection->insert('neos_neos_workspace_role', [
'content_repository_id' => $this->contentRepositoryId->value,
'workspace_name' => $workspaceName->value,
'subject_type' => WorkspaceSubjectType::USER->value,
'subject_type' => WorkspaceRoleSubjectType::USER->value,
'subject' => $workspaceOwner,
'role' => WorkspaceRole::COLLABORATOR->value,
]);
Expand Down
14 changes: 2 additions & 12 deletions Neos.Media.Browser/Classes/Controller/UsageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@

use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindClosestNodeFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFound;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\ActionController;
Expand Down Expand Up @@ -107,19 +104,12 @@ public function relatedNodesAction(AssetInterface $asset)

$contentRepository = $this->contentRepositoryRegistry->get($usage->getContentRepositoryId());

$workspace = $contentRepository->getWorkspaces()->find(
fn (Workspace $potentialWorkspace) => $potentialWorkspace->currentContentStreamId->equals($usage->getContentStreamId())
);
$workspace = $contentRepository->getWorkspaceFinder()->findOneByName($usage->getWorkspaceName());

// FIXME: AssetUsageReference->workspaceName ?
$nodeAggregate = $contentRepository->getContentGraph($workspace->workspaceName)->findNodeAggregateById(
$usage->getNodeAggregateId()
);
try {
$nodeType = $contentRepository->getNodeTypeManager()->getNodeType($nodeAggregate->nodeTypeName);
} catch (NodeTypeNotFound $e) {
$nodeType = null;
}
$nodeType = $contentRepository->getNodeTypeManager()->getNodeType($nodeAggregate->nodeTypeName);

$accessible = $this->domainUserService->currentUserCanReadWorkspace($workspace);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,21 @@
<f:switch expression="{true}">
<f:case value="{inaccessibleRelation.workspace.personalWorkspace}">
<i class="fas fa-user"
title="{neos:backend.translate(id: 'workspaces.personalWorkspace', source: 'Modules', package: 'Neos.Neos')}"
title="{neos:backend.translate(id: 'workspaces.personalWorkspace', source: 'Main', package: 'Neos.Workspace.Ui')}"
data-neos-toggle="tooltip"></i>
{neos:backend.translate(id: 'workspaces.personalWorkspace', source: 'Modules', package: 'Neos.Neos')}
{neos:backend.translate(id: 'workspaces.personalWorkspace', source: 'Main', package: 'Neos.Workspace.Ui')}
</f:case>
<f:case value="{inaccessibleRelation.workspace.privateWorkspace}">
<i class="fas fa-shield"
title="{neos:backend.translate(id: 'workspaces.privateWorkspace', source: 'Modules', package: 'Neos.Neos')}"
title="{neos:backend.translate(id: 'workspaces.privateWorkspace', source: 'Main', package: 'Neos.Workspace.Ui')}"
data-neos-toggle="tooltip"></i>
{neos:backend.translate(id: 'workspaces.privateWorkspace', source: 'Modules', package:
'Neos.Neos')}
{neos:backend.translate(id: 'workspaces.privateWorkspace', source: 'Main', package: 'Neos.Workspace.Ui')}
</f:case>
<f:case value="{inaccessibleRelation.workspace.internalWorkspace}">
<i class="fas fa-group"
title="{neos:backend.translate(id: 'workspaces.internalWorkspace', source: 'Modules', package: 'Neos.Neos')}"
title="{neos:backend.translate(id: 'workspaces.internalWorkspace', source: 'Main', package: 'Neos.Workspace.Ui')}"
data-neos-toggle="tooltip"></i>
{neos:backend.translate(id: 'workspaces.internalWorkspace', source: 'Modules', package:
'Neos.Neos')}
{neos:backend.translate(id: 'workspaces.internalWorkspace', source: 'Main', package: 'Neos.Workspace.Ui')}
</f:case>
<f:defaultCase>
---
Expand Down Expand Up @@ -96,8 +94,8 @@
<f:if condition="{nodeInformation.documentNode}">
<f:then>
<neos:link.node node="{nodeInformation.documentNode}" target="_blank"
title="{neos:backend.translate(id: 'workspaces.openPageInWorkspace', source: 'Modules', package: 'Neos.Neos', arguments: {0: nodeInformation.workspace.workspaceTitle.value})}">
<span title="{f:render(partial: 'Module/Shared/DocumentBreadcrumb', arguments: {node: nodeInformation.documentNode})}" data-neos-toggle="tooltip">{nodeInformation.documentNode.label}</span>
title="{neos:backend.translate(id: 'workspaces.openPageInWorkspace', source: 'Main', package: 'Neos.Workspace.Ui', arguments: {0: nodeInformation.workspace.workspaceTitle.value})}">
<span title="{f:render(partial: 'Module/Shared/DocumentBreadcrumb', arguments: {node: nodeInformation.documentNode})}" data-neos-toggle="tooltip">{neos:node.label(node: nodeInformation.documentNode)}</span>
<i class="fas fa-external-link-alt"></i>
</neos:link.node>
</f:then>
Expand All @@ -113,7 +111,7 @@
title="{f:if(condition: nodeInformation.node.nodeType.label, then: '{neos:backend.translate(id: nodeInformation.node.nodeType.label, package: \'Neos.Neos\')}', else: '{nodeInformation.node.nodeType.name}')}"
data-neos-toggle="tooltip" data-placement="left"></i>
</f:if>
<span title="{nodeInformation.node.path}" data-neos-toggle="tooltip" data-placement="left">{nodeInformation.node.label}</span>
<span title="{nodeInformation.node.path}" data-neos-toggle="tooltip" data-placement="left">{neos:node.label(node: nodeInformation.node)}</span>
</td>
<td>
<f:if condition="{contentDimensions}">
Expand All @@ -124,19 +122,19 @@
<f:if condition="{userWorkspace} == {nodeInformation.workspace}">
<f:then>
<i class="fas fa-user"
title="{neos:backend.translate(id: 'workspaces.personalWorkspace', source: 'Modules', package: 'Neos.Neos')}"
title="{neos:backend.translate(id: 'workspaces.personalWorkspace', source: 'Main', package: 'Neos.Workspace.Ui')}"
data-neos-toggle="tooltip"></i>
</f:then>
<f:else>
<f:if condition="{nodeInformation.workspace.privateWorkspace}">
<f:then>
<i class="fas fa-shield"
title="{neos:backend.translate(id: 'workspaces.privateWorkspace', source: 'Modules', package: 'Neos.Neos')}"
title="{neos:backend.translate(id: 'workspaces.privateWorkspace', source: 'Main', package: 'Neos.Workspace.Ui')}"
data-neos-toggle="tooltip"></i>
</f:then>
<f:else>
<i class="fas fa-group"
title="{neos:backend.translate(id: 'workspaces.internalWorkspace', source: 'Modules', package: 'Neos.Neos')}"
title="{neos:backend.translate(id: 'workspaces.internalWorkspace', source: 'Main', package: 'Neos.Workspace.Ui')}"
data-neos-toggle="tooltip"></i>
</f:else>
</f:if>
Expand Down
Loading

0 comments on commit 4ea3bbe

Please sign in to comment.