-
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '9.0' into task/contentCacheFlusher-followup
- Loading branch information
Showing
494 changed files
with
10,382 additions
and
8,273 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
80 changes: 0 additions & 80 deletions
80
Neos.ContentGraph.DoctrineDbalAdapter/src/ContentGraphFactory.php
This file was deleted.
Oops, something went wrong.
174 changes: 174 additions & 0 deletions
174
Neos.ContentGraph.DoctrineDbalAdapter/src/ContentGraphReadModelAdapter.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,174 @@ | ||
<?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\Projection\ContentGraph\ContentGraphReadModelInterface; | ||
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 | ||
*/ | ||
final readonly class ContentGraphReadModelAdapter implements ContentGraphReadModelInterface | ||
{ | ||
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)); | ||
} | ||
|
||
public function countNodes(): int | ||
{ | ||
$countNodesStatement = <<<SQL | ||
SELECT | ||
COUNT(*) | ||
FROM | ||
{$this->tableNames->node()} | ||
SQL; | ||
try { | ||
return (int)$this->dbal->fetchOne($countNodesStatement); | ||
} catch (Exception $e) { | ||
throw new \RuntimeException(sprintf('Failed to count rows in database: %s', $e->getMessage()), 1701444590, $e); | ||
} | ||
} | ||
|
||
/** | ||
* @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'] | ||
); | ||
} | ||
} |
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
Oops, something went wrong.