Skip to content

Commit

Permalink
TASK: Simplify requireContentStream by removing one sql query
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Oct 31, 2024
1 parent 41b4496 commit 77eac51
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphReadModelInterface;
use Neos\ContentRepository\Core\SharedModel\Exception\ContentStreamDoesNotExistYet;
use Neos\ContentRepository\Core\SharedModel\Exception\WorkspaceDoesNotExist;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace;
Expand Down Expand Up @@ -52,7 +53,10 @@ public function isContentStreamClosed(ContentStreamId $contentStreamId): bool
{
$contentStream = $this->contentGraphReadModel->findContentStreamById($contentStreamId);
if ($contentStream === null) {
throw new \InvalidArgumentException(sprintf('Failed to find content stream with id "%s"', $contentStreamId->value), 1729863973);
throw new ContentStreamDoesNotExistYet(
'Content stream "' . $contentStreamId->value . '" does not exist.',
1521386692
);
}
return $contentStream->isClosed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,6 @@ protected function requireContentStream(
CommandHandlingDependencies $commandHandlingDependencies
): ContentStreamId {
$contentStreamId = $commandHandlingDependencies->getContentGraph($workspaceName)->getContentStreamId();
if (!$commandHandlingDependencies->contentStreamExists($contentStreamId)) {
throw new ContentStreamDoesNotExistYet(
'Content stream for "' . $workspaceName->value . '" does not exist yet.',
1521386692
);
}

if ($commandHandlingDependencies->isContentStreamClosed($contentStreamId)) {
throw new ContentStreamIsClosed(
'Content stream "' . $contentStreamId->value . '" is closed.',
Expand Down

0 comments on commit 77eac51

Please sign in to comment.