-
-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
!!! TASK: Add workspace content stream mapping to content graph projection #5096
Merged
kitsunet
merged 26 commits into
9.0
from
task/add-workspace-contentstream-mapping-to-contentgraph
Oct 17, 2024
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
2db672e
TASK: Add workspace content stream mapping to content graph projection
bwaidelich f3f9571
!!! TASK: Replace dedicated Workspace and ContentStream projections
bwaidelich fab9d2d
wip
bwaidelich a3e6414
wip
bwaidelich 17e39a8
TASK: Post rebase phpstan adjustments
mhsdesign 2a781d2
TASK: Reintroduce content graph / cr read model cache
mhsdesign 80a302f
TASK: Fix `I expect the content stream "user-cs-identifier" to not ex…
mhsdesign d0839e4
TASK: Use `EmbedsContentStreamId` like previously to `updateContentSt…
mhsdesign 468c80d
TASK: Remove obsolete import
mhsdesign 4ea3bbe
Merge remote-tracking branch 'origin/9.0' into task/add-workspace-con…
mhsdesign db7861f
TASK: Fixup after merge of asset usage refactoring
mhsdesign c34456b
TASK: Adjust to `find*` vs `get*` convention
mhsdesign 8348a1b
Merge remote-tracking branch 'origin/9.0' into task/add-workspace-con…
mhsdesign 55a8e57
TASK: Adjust to `find*` vs `get*` convention (in `findContentStreams`)
mhsdesign e59a653
Merge remote-tracking branch 'origin/9.0' into task/add-workspace-con…
mhsdesign a0dd44c
Replace `WorkspaceFinder` usage in `UsageController`
bwaidelich 25afe96
TASK: Php-stanize UsageController and fix php error
mhsdesign b41f5b5
Fix parameter name in content graph projection
bwaidelich 2a8b490
Revert "TASK: Reintroduce content graph / cr read model cache"
mhsdesign 041f239
TASK: Migrate findUnusedAndRemovedContentStreams from SQL to PHP
mhsdesign f604674
TASK: Use `Workspace->isRootWorkspace()`
mhsdesign acd3833
TASK: Prevent `default` arm to throw as we can handle possibly all ev…
mhsdesign c91f24f
TASK: Move `getContentGraph` again upwards
mhsdesign 738b68b
Merge remote-tracking branch 'origin/9.0' into task/add-workspace-con…
mhsdesign 4a652d2
BUGFIX: Fix logic of `Workspace::isRootWorkspace`
mhsdesign a18801b
TASK: Adjust casings of columns
mhsdesign File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
80 changes: 0 additions & 80 deletions
80
Neos.ContentGraph.DoctrineDbalAdapter/src/ContentGraphFactory.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
160 changes: 160 additions & 0 deletions
160
Neos.ContentGraph.DoctrineDbalAdapter/src/ContentRepositoryReadModelAdapter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Neos.ContentGraph.DoctrineDbalAdapter package. | ||
* | ||
* (c) Contributors of the Neos Project - www.neos.io | ||
* | ||
* This package is Open Source Software. For the full copyright and license | ||
* information, please view the LICENSE file which was distributed with this | ||
* source code. | ||
*/ | ||
|
||
namespace Neos\ContentGraph\DoctrineDbalAdapter; | ||
|
||
use Doctrine\DBAL\Connection; | ||
use Doctrine\DBAL\Exception; | ||
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\ContentGraph; | ||
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\NodeFactory; | ||
use Neos\ContentRepository\Core\ContentRepositoryReadModelAdapterInterface; | ||
use Neos\ContentRepository\Core\NodeType\NodeTypeManager; | ||
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId; | ||
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStream; | ||
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; | ||
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreams; | ||
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamStatus; | ||
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace; | ||
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; | ||
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspaces; | ||
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceStatus; | ||
use Neos\EventStore\Model\Event\Version; | ||
|
||
/** | ||
* @internal only used inside the | ||
* @see ContentRepositoryReadModel | ||
*/ | ||
final readonly class ContentRepositoryReadModelAdapter implements ContentRepositoryReadModelAdapterInterface | ||
{ | ||
public function __construct( | ||
private Connection $dbal, | ||
private NodeFactory $nodeFactory, | ||
private ContentRepositoryId $contentRepositoryId, | ||
private NodeTypeManager $nodeTypeManager, | ||
private ContentGraphTableNames $tableNames | ||
) { | ||
} | ||
|
||
public function buildContentGraph(WorkspaceName $workspaceName, ContentStreamId $contentStreamId): ContentGraph | ||
{ | ||
return new ContentGraph($this->dbal, $this->nodeFactory, $this->contentRepositoryId, $this->nodeTypeManager, $this->tableNames, $workspaceName, $contentStreamId); | ||
} | ||
|
||
public function findWorkspaceByName(WorkspaceName $workspaceName): ?Workspace | ||
{ | ||
$workspaceByNameStatement = <<<SQL | ||
SELECT | ||
name, baseWorkspaceName, currentContentStreamId, status | ||
FROM | ||
{$this->tableNames->workspace()} | ||
WHERE | ||
name = :workspaceName | ||
LIMIT 1 | ||
SQL; | ||
try { | ||
$row = $this->dbal->fetchAssociative($workspaceByNameStatement, [ | ||
'workspaceName' => $workspaceName->value, | ||
]); | ||
} catch (Exception $e) { | ||
throw new \RuntimeException(sprintf('Failed to load workspace from database: %s', $e->getMessage()), 1716486077, $e); | ||
} | ||
if ($row === false) { | ||
return null; | ||
} | ||
return self::workspaceFromDatabaseRow($row); | ||
} | ||
|
||
public function findWorkspaces(): Workspaces | ||
{ | ||
$workspacesStatement = <<<SQL | ||
SELECT | ||
name, baseWorkspaceName, currentContentStreamId, status | ||
FROM | ||
{$this->tableNames->workspace()} | ||
SQL; | ||
try { | ||
$rows = $this->dbal->fetchAllAssociative($workspacesStatement); | ||
} catch (Exception $e) { | ||
throw new \RuntimeException(sprintf('Failed to load workspaces from database: %s', $e->getMessage()), 1716902981, $e); | ||
} | ||
return Workspaces::fromArray(array_map(self::workspaceFromDatabaseRow(...), $rows)); | ||
} | ||
|
||
public function findContentStreamById(ContentStreamId $contentStreamId): ?ContentStream | ||
{ | ||
$contentStreamByIdStatement = <<<SQL | ||
SELECT | ||
id, sourceContentStreamId, status, version, removed | ||
FROM | ||
{$this->tableNames->contentStream()} | ||
WHERE | ||
id = :contentStreamId | ||
LIMIT 1 | ||
SQL; | ||
try { | ||
$row = $this->dbal->fetchAssociative($contentStreamByIdStatement, [ | ||
'contentStreamId' => $contentStreamId->value, | ||
]); | ||
} catch (Exception $e) { | ||
throw new \RuntimeException(sprintf('Failed to load content stream from database: %s', $e->getMessage()), 1716903166, $e); | ||
} | ||
if ($row === false) { | ||
return null; | ||
} | ||
return self::contentStreamFromDatabaseRow($row); | ||
} | ||
|
||
public function findContentStreams(): ContentStreams | ||
{ | ||
$contentStreamsStatement = <<<SQL | ||
SELECT | ||
id, sourceContentStreamId, status, version, removed | ||
FROM | ||
{$this->tableNames->contentStream()} | ||
SQL; | ||
try { | ||
$rows = $this->dbal->fetchAllAssociative($contentStreamsStatement); | ||
} catch (Exception $e) { | ||
throw new \RuntimeException(sprintf('Failed to load content streams from database: %s', $e->getMessage()), 1716903042, $e); | ||
} | ||
return ContentStreams::fromArray(array_map(self::contentStreamFromDatabaseRow(...), $rows)); | ||
} | ||
|
||
/** | ||
* @param array<string, mixed> $row | ||
*/ | ||
private static function workspaceFromDatabaseRow(array $row): Workspace | ||
{ | ||
return new Workspace( | ||
WorkspaceName::fromString($row['name']), | ||
isset($row['baseWorkspaceName']) ? WorkspaceName::fromString($row['baseWorkspaceName']) : null, | ||
ContentStreamId::fromString($row['currentContentStreamId']), | ||
WorkspaceStatus::from($row['status']), | ||
); | ||
} | ||
|
||
/** | ||
* @param array<string, mixed> $row | ||
*/ | ||
private static function contentStreamFromDatabaseRow(array $row): ContentStream | ||
{ | ||
return new ContentStream( | ||
ContentStreamId::fromString($row['id']), | ||
isset($row['sourceContentStreamId']) ? ContentStreamId::fromString($row['sourceContentStreamId']) : null, | ||
ContentStreamStatus::from($row['status']), | ||
Version::fromInteger((int)$row['version']), | ||
(bool)$row['removed'] | ||
); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 fyi (for other reviewers) while these namings are not perfect - they are not the final ones either :)
in #5272 we can discuss the final final final draft:)