Skip to content
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: Remove references to CommandResult in return types #5061

Merged
merged 6 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ Feature: Workspace rebasing - conflicting changes
| nodeAggregateId | "nody-mc-nodeface" |
| originDimensionSpacePoint | {} |
| propertyValues | {"text": "Original"} |
# we need to ensure that the projections are up to date now; otherwise a content stream is forked with an out-
# of-date base version. This means the content stream can never be merged back, but must always be rebased.
And the command CreateWorkspace is executed with payload:
| Key | Value |
| workspaceName | "user-test" |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ Feature: Workspace based content publishing
| nodeAggregateId | "nody-mc-nodeface" |
| originDimensionSpacePoint | {} |
| propertyValues | {"text": "Original"} |
# we need to ensure that the projections are up to date now; otherwise a content stream is forked with an out-
# of-date base version. This means the content stream can never be merged back, but must always be rebased.
And the command CreateWorkspace is executed with payload:
| Key | Value |
| workspaceName | "user-test" |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ Feature: Publishing hide/show scenario of nodes
| nodeAggregateId | "sir-nodeward-nodington-iii" |
| coveredDimensionSpacePoint | {} |
| nodeVariantSelectionStrategy | "allVariants" |
# we need to ensure that the projections are up to date now; otherwise a content stream is forked with an out-
# of-date base version. This means the content stream can never be merged back, but must always be rebased.
Given the command CreateWorkspace is executed with payload:
| Key | Value |
| workspaceName | "user-test" |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ Feature: Workspace discarding - basic functionality
| nodeAggregateId | "nody-mc-nodeface" |
| originDimensionSpacePoint | {} |
| propertyValues | {"text": "Original"} |
# we need to ensure that the projections are up to date now; otherwise a content stream is forked with an out-
# of-date base version. This means the content stream can never be merged back, but must always be rebased.

And the command CreateWorkspace is executed with payload:
| Key | Value |
| workspaceName | "user-test" |
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
namespace Neos\ContentRepository\Core;

use Neos\ContentRepository\Core\CommandHandler\CommandInterface;
use Neos\ContentRepository\Core\CommandHandler\CommandResult;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface;
use Neos\ContentRepository\Core\Projection\ContentStream\ContentStreamFinder;
use Neos\ContentRepository\Core\Projection\Workspace\WorkspaceFinder;
Expand All @@ -41,9 +40,9 @@ public function __construct(private readonly ContentRepository $contentRepositor
{
}

public function handle(CommandInterface $command): CommandResult
public function handle(CommandInterface $command): void
{
return $this->contentRepository->handle($command);
$this->contentRepository->handle($command);
}

public function getWorkspaceFinder(): WorkspaceFinder
Expand Down
6 changes: 2 additions & 4 deletions Neos.ContentRepository.Core/Classes/ContentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

use Neos\ContentRepository\Core\CommandHandler\CommandBus;
use Neos\ContentRepository\Core\CommandHandler\CommandInterface;
use Neos\ContentRepository\Core\CommandHandler\CommandResult;
use Neos\ContentRepository\Core\Dimension\ContentDimensionSourceInterface;
use Neos\ContentRepository\Core\DimensionSpace\InterDimensionalVariationGraph;
use Neos\ContentRepository\Core\EventStore\DecoratedEvent;
Expand Down Expand Up @@ -94,9 +93,8 @@ public function __construct(
* The only API to send commands (mutation intentions) to the system.
*
* @param CommandInterface $command
* @return CommandResult
*/
public function handle(CommandInterface $command): CommandResult
public function handle(CommandInterface $command): void
{
// the commands only calculate which events they want to have published, but do not do the
// publishing themselves
Expand Down Expand Up @@ -131,7 +129,7 @@ public function handle(CommandInterface $command): CommandResult
$eventsToPublish->expectedVersion,
);

return $this->eventPersister->publishEvents($eventsToPublish);
$this->eventPersister->publishEvents($eventsToPublish);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

namespace Neos\ContentRepository\Core\EventStore;

use Neos\ContentRepository\Core\CommandHandler\CommandResult;
use Neos\ContentRepository\Core\CommandHandler\PendingProjections;
use Neos\ContentRepository\Core\Projection\ProjectionCatchUpTriggerInterface;
use Neos\ContentRepository\Core\Projection\Projections;
use Neos\ContentRepository\Core\Projection\WithMarkStaleInterface;
use Neos\EventStore\EventStoreInterface;
use Neos\EventStore\Exception\ConcurrencyException;
use Neos\EventStore\Model\Events;
Expand All @@ -31,13 +29,12 @@ public function __construct(

/**
* @param EventsToPublish $eventsToPublish
* @return CommandResult
* @throws ConcurrencyException in case the expectedVersion does not match
*/
public function publishEvents(EventsToPublish $eventsToPublish): CommandResult
public function publishEvents(EventsToPublish $eventsToPublish): void
{
if ($eventsToPublish->events->isEmpty()) {
return new CommandResult();
return;
}
// the following logic could also be done in an AppEventStore::commit method (being called
// directly from the individual Command Handlers).
Expand All @@ -59,6 +56,5 @@ public function publishEvents(EventsToPublish $eventsToPublish): CommandResult
);

$this->projectionCatchUpTrigger->triggerCatchUp($pendingProjections->projections);
return new CommandResult();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

use Neos\ContentRepository\Core\CommandHandler\CommandHandlerInterface;
use Neos\ContentRepository\Core\CommandHandler\CommandInterface;
use Neos\ContentRepository\Core\CommandHandler\CommandResult;
use Neos\ContentRepository\Core\CommandHandlingDependencies;
use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\EventStore\DecoratedEvent;
Expand Down Expand Up @@ -279,7 +278,7 @@ private function publishContentStream(
ContentStreamId $contentStreamId,
WorkspaceName $baseWorkspaceName,
ContentStreamId $baseContentStreamId,
): ?CommandResult {
): void {
$baseWorkspaceContentStreamName = ContentStreamEventStreamName::fromContentStreamId(
$baseContentStreamId
);
Expand Down Expand Up @@ -324,10 +323,10 @@ private function publishContentStream(
}

if (count($events) === 0) {
return null;
return;
}
try {
return $this->eventPersister->publishEvents(
$this->eventPersister->publishEvents(
new EventsToPublish(
$baseWorkspaceContentStreamName->getEventStreamName(),
Events::fromArray($events),
Expand Down Expand Up @@ -794,8 +793,6 @@ private function handleDiscardWorkspace(
)
);

// It is safe to only return the last command result,
// as the commands which were rebased are already executed "synchronously"
return new EventsToPublish(
$streamName,
$events,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Neos\ContentRepository\Core\Service;

use Neos\ContentRepository\Core\CommandHandler\CommandResult;
use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceInterface;
use Neos\ContentRepository\Core\Feature\ContentStreamEventStreamName;
Expand All @@ -20,8 +19,6 @@
*/
class ContentStreamPruner implements ContentRepositoryServiceInterface
{
private ?CommandResult $lastCommandResult;

public function __construct(
private readonly ContentRepository $contentRepository,
private readonly EventStoreInterface $eventStore,
Expand Down Expand Up @@ -51,7 +48,7 @@ public function prune(bool $removeTemporary = false): iterable
);

foreach ($unusedContentStreams as $contentStream) {
$this->lastCommandResult = $this->contentRepository->handle(
$this->contentRepository->handle(
RemoveContentStream::create($contentStream)
);
}
Expand Down Expand Up @@ -93,9 +90,4 @@ public function pruneAll(): void
$this->eventStore->deleteStream($streamName);
}
}

public function getLastCommandResult(): ?CommandResult
{
return $this->lastCommandResult;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ public function executeMigration(ExecuteMigration $command): void
}

foreach ($command->migrationConfiguration->getMigration() as $migrationDescription) {
/** array $migrationDescription */
$this->executeSubMigrationAndBlock(
$this->executeSubMigration(
$migrationDescription,
$sourceWorkspace,
$targetWorkspace
Expand All @@ -121,7 +120,7 @@ public function executeMigration(ExecuteMigration $command): void
* @param array<string,mixed> $migrationDescription
* @throws MigrationException
*/
protected function executeSubMigrationAndBlock(
protected function executeSubMigration(
array $migrationDescription,
Workspace $workspaceForReading,
Workspace $workspaceForWriting,
Expand Down Expand Up @@ -153,7 +152,7 @@ protected function executeSubMigrationAndBlock(
}

if ($transformations->containsGlobal()) {
$transformations->executeGlobalAndBlock($workspaceForWriting->workspaceName);
$transformations->executeGlobal($workspaceForWriting->workspaceName);
} elseif ($transformations->containsNodeAggregateBased()) {
$contentGraph = $this->contentRepository->getContentGraph($workspaceForReading->workspaceName);
foreach ($contentGraph->findUsedNodeTypeNames() as $nodeTypeName) {
Expand All @@ -163,7 +162,7 @@ protected function executeSubMigrationAndBlock(
) as $nodeAggregate
) {
if ($filters->matchesNodeAggregate($nodeAggregate)) {
$transformations->executeNodeAggregateBasedAndBlock($nodeAggregate, $workspaceForWriting->workspaceName, $workspaceForWriting->currentContentStreamId);
$transformations->executeNodeAggregateBased($nodeAggregate, $workspaceForWriting->workspaceName, $workspaceForWriting->currentContentStreamId);
}
}
}
Expand All @@ -189,7 +188,7 @@ protected function executeSubMigrationAndBlock(
);

if ($filters->matchesNode($node)) {
$transformations->executeNodeBasedAndBlock(
$transformations->executeNodeBased(
$node,
$coveredDimensionSpacePoints,
$workspaceForWriting->workspaceName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

namespace Neos\ContentRepository\NodeMigration\Transformation;

use Neos\ContentRepository\Core\CommandHandler\CommandResult;
use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\Feature\DimensionSpaceAdjustment\Command\AddDimensionShineThrough;
Expand Down Expand Up @@ -50,8 +49,8 @@ public function __construct(

public function execute(
WorkspaceName $workspaceNameForWriting,
): CommandResult {
return $this->contentRepository->handle(
): void {
$this->contentRepository->handle(
AddDimensionShineThrough::create(
$workspaceNameForWriting,
$this->from,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

namespace Neos\ContentRepository\NodeMigration\Transformation;

use Neos\ContentRepository\Core\CommandHandler\CommandResult;
use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet;
use Neos\ContentRepository\Core\Feature\NodeModification\Command\SetSerializedNodeProperties;
Expand Down Expand Up @@ -59,14 +58,14 @@ public function execute(
DimensionSpacePointSet $coveredDimensionSpacePoints,
WorkspaceName $workspaceNameForWriting,
ContentStreamId $contentStreamForWriting
): ?CommandResult {
): void {
if ($this->serializedValue === null) {
// we don't need to unset a non-existing property
return null;
return;
}

if (!$node->hasProperty($this->newPropertyName)) {
return $this->contentRepository->handle(
$this->contentRepository->handle(
SetSerializedNodeProperties::create(
$workspaceNameForWriting,
$node->aggregateId,
Expand All @@ -81,8 +80,6 @@ public function execute(
)
);
}

return null;
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

namespace Neos\ContentRepository\NodeMigration\Transformation;

use Neos\ContentRepository\Core\CommandHandler\CommandResult;
use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\Feature\NodeTypeChange\Command\ChangeNodeAggregateType;
use Neos\ContentRepository\Core\Feature\NodeTypeChange\Dto\NodeAggregateTypeChangeChildConstraintConflictResolutionStrategy;
Expand Down Expand Up @@ -65,8 +64,8 @@ public function execute(
NodeAggregate $nodeAggregate,
WorkspaceName $workspaceNameForWriting,
ContentStreamId $contentStreamForWriting
): CommandResult {
return $this->contentRepository->handle(ChangeNodeAggregateType::create(
): void {
$this->contentRepository->handle(ChangeNodeAggregateType::create(
$workspaceNameForWriting,
$nodeAggregate->nodeAggregateId,
NodeTypeName::fromString($this->newType),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

namespace Neos\ContentRepository\NodeMigration\Transformation;

use Neos\ContentRepository\Core\CommandHandler\CommandResult;
use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet;
use Neos\ContentRepository\Core\Feature\NodeModification\Command\SetSerializedNodeProperties;
Expand Down Expand Up @@ -106,7 +105,7 @@ public function execute(
DimensionSpacePointSet $coveredDimensionSpacePoints,
WorkspaceName $workspaceNameForWriting,
ContentStreamId $contentStreamForWriting
): ?CommandResult {
): void {
$currentProperty = $node->properties->serialized()->getProperty($this->propertyName);
if ($currentProperty !== null) {
$value = $currentProperty->value;
Expand All @@ -128,7 +127,7 @@ public function execute(
$newValueWithReplacedCurrentValue
);

return $this->contentRepository->handle(
$this->contentRepository->handle(
SetSerializedNodeProperties::create(
$workspaceNameForWriting,
$node->aggregateId,
Expand All @@ -143,8 +142,6 @@ public function execute(
)
);
}

return null;
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

namespace Neos\ContentRepository\NodeMigration\Transformation;

use Neos\ContentRepository\Core\CommandHandler\CommandResult;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;

/**
Expand All @@ -27,5 +25,5 @@ interface GlobalTransformationInterface
{
public function execute(
WorkspaceName $workspaceNameForWriting,
): CommandResult;
): void;
}
Loading
Loading