-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3769 from neos/feature/conflict-resolution-03/reb…
…ase-during-publish FEATURE: Integrate conflict resolution with publish/discard dialog workflow
- Loading branch information
Showing
27 changed files
with
871 additions
and
357 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
96 changes: 96 additions & 0 deletions
96
Classes/Application/PublishChangesInDocument/PublishChangesInDocumentCommandHandler.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,96 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Neos.Neos 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. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Neos\Neos\Ui\Application\PublishChangesInDocument; | ||
|
||
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Exception\WorkspaceRebaseFailed; | ||
use Neos\ContentRepository\Core\SharedModel\Exception\NodeAggregateCurrentlyDoesNotExist; | ||
use Neos\ContentRepository\Core\SharedModel\Exception\NodeAggregateDoesCurrentlyNotCoverDimensionSpacePoint; | ||
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; | ||
use Neos\Flow\Annotations as Flow; | ||
use Neos\Neos\Domain\NodeLabel\NodeLabelGeneratorInterface; | ||
use Neos\Neos\Domain\Service\WorkspacePublishingService; | ||
use Neos\Neos\Ui\Application\Shared\ConflictsOccurred; | ||
use Neos\Neos\Ui\Application\Shared\PublishSucceeded; | ||
use Neos\Neos\Ui\Controller\TranslationTrait; | ||
use Neos\Neos\Ui\Infrastructure\ContentRepository\ConflictsFactory; | ||
|
||
/** | ||
* The application layer level command handler to perform publication of | ||
* all changes recorded for a given document | ||
* | ||
* @internal for communication within the Neos UI only | ||
*/ | ||
#[Flow\Scope("singleton")] | ||
final class PublishChangesInDocumentCommandHandler | ||
{ | ||
use TranslationTrait; | ||
|
||
#[Flow\Inject] | ||
protected ContentRepositoryRegistry $contentRepositoryRegistry; | ||
|
||
#[Flow\Inject] | ||
protected WorkspacePublishingService $workspacePublishingService; | ||
|
||
#[Flow\Inject] | ||
protected NodeLabelGeneratorInterface $nodeLabelGenerator; | ||
|
||
/** | ||
* @throws NodeAggregateCurrentlyDoesNotExist | ||
*/ | ||
public function handle( | ||
PublishChangesInDocumentCommand $command | ||
): PublishSucceeded|ConflictsOccurred { | ||
try { | ||
$publishingResult = $this->workspacePublishingService->publishChangesInDocument( | ||
$command->contentRepositoryId, | ||
$command->workspaceName, | ||
$command->documentId | ||
); | ||
|
||
$workspace = $this->contentRepositoryRegistry->get($command->contentRepositoryId)->findWorkspaceByName( | ||
$command->workspaceName | ||
); | ||
|
||
return new PublishSucceeded( | ||
numberOfAffectedChanges: $publishingResult->numberOfPublishedChanges, | ||
baseWorkspaceName: $workspace?->baseWorkspaceName?->value | ||
); | ||
} catch (NodeAggregateCurrentlyDoesNotExist $e) { | ||
throw new \RuntimeException( | ||
$this->getLabel('NodeNotPublishedMissingParentNode'), | ||
1705053430, | ||
$e | ||
); | ||
} catch (NodeAggregateDoesCurrentlyNotCoverDimensionSpacePoint $e) { | ||
throw new \RuntimeException( | ||
$this->getLabel('NodeNotPublishedParentNodeNotInCurrentDimension'), | ||
1705053432, | ||
$e | ||
); | ||
} catch (WorkspaceRebaseFailed $e) { | ||
$conflictsFactory = new ConflictsFactory( | ||
contentRepository: $this->contentRepositoryRegistry | ||
->get($command->contentRepositoryId), | ||
nodeLabelGenerator: $this->nodeLabelGenerator, | ||
workspaceName: $command->workspaceName, | ||
preferredDimensionSpacePoint: $command->preferredDimensionSpacePoint | ||
); | ||
|
||
return new ConflictsOccurred( | ||
conflicts: $conflictsFactory->fromWorkspaceRebaseFailed($e) | ||
); | ||
} | ||
} | ||
} |
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
76 changes: 76 additions & 0 deletions
76
Classes/Application/PublishChangesInSite/PublishChangesInSiteCommandHandler.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,76 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Neos.Neos.Ui 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. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Neos\Neos\Ui\Application\PublishChangesInSite; | ||
|
||
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Exception\WorkspaceRebaseFailed; | ||
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; | ||
use Neos\Flow\Annotations as Flow; | ||
use Neos\Neos\Domain\NodeLabel\NodeLabelGeneratorInterface; | ||
use Neos\Neos\Domain\Service\WorkspacePublishingService; | ||
use Neos\Neos\Ui\Application\Shared\ConflictsOccurred; | ||
use Neos\Neos\Ui\Application\Shared\PublishSucceeded; | ||
use Neos\Neos\Ui\Infrastructure\ContentRepository\ConflictsFactory; | ||
|
||
/** | ||
* The application layer level command handler to perform publication of | ||
* all changes recorded for a given site | ||
* | ||
* @internal for communication within the Neos UI only | ||
*/ | ||
#[Flow\Scope("singleton")] | ||
final class PublishChangesInSiteCommandHandler | ||
{ | ||
#[Flow\Inject] | ||
protected ContentRepositoryRegistry $contentRepositoryRegistry; | ||
|
||
#[Flow\Inject] | ||
protected WorkspacePublishingService $workspacePublishingService; | ||
|
||
#[Flow\Inject] | ||
protected NodeLabelGeneratorInterface $nodeLabelGenerator; | ||
|
||
public function handle( | ||
PublishChangesInSiteCommand $command | ||
): PublishSucceeded|ConflictsOccurred { | ||
try { | ||
$publishingResult = $this->workspacePublishingService->publishChangesInSite( | ||
$command->contentRepositoryId, | ||
$command->workspaceName, | ||
$command->siteId | ||
); | ||
|
||
$workspace = $this->contentRepositoryRegistry->get($command->contentRepositoryId)->findWorkspaceByName( | ||
$command->workspaceName | ||
); | ||
|
||
return new PublishSucceeded( | ||
numberOfAffectedChanges: $publishingResult->numberOfPublishedChanges, | ||
baseWorkspaceName: $workspace?->baseWorkspaceName?->value | ||
); | ||
} catch (WorkspaceRebaseFailed $e) { | ||
$conflictsFactory = new ConflictsFactory( | ||
contentRepository: $this->contentRepositoryRegistry | ||
->get($command->contentRepositoryId), | ||
nodeLabelGenerator: $this->nodeLabelGenerator, | ||
workspaceName: $command->workspaceName, | ||
preferredDimensionSpacePoint: $command->preferredDimensionSpacePoint | ||
); | ||
|
||
return new ConflictsOccurred( | ||
conflicts: $conflictsFactory->fromWorkspaceRebaseFailed($e) | ||
); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Neos.Neos.Ui 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. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Neos\Neos\Ui\Application\Shared; | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
|
||
/** | ||
* @internal for communication within the Neos UI only | ||
*/ | ||
#[Flow\Proxy(false)] | ||
final readonly class Conflicts implements \JsonSerializable, \Countable | ||
{ | ||
/** @var Conflict[] */ | ||
private array $items; | ||
|
||
public function __construct(Conflict ...$items) | ||
{ | ||
$this->items = array_values($items); | ||
} | ||
|
||
public function jsonSerialize(): mixed | ||
{ | ||
return $this->items; | ||
} | ||
|
||
public function count(): int | ||
{ | ||
return count($this->items); | ||
} | ||
} |
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,34 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Neos.Neos.Ui 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. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Neos\Neos\Ui\Application\Shared; | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
|
||
/** | ||
* @internal for communication within the Neos UI only | ||
*/ | ||
#[Flow\Proxy(false)] | ||
final readonly class ConflictsOccurred implements \JsonSerializable | ||
{ | ||
public function __construct( | ||
public readonly Conflicts $conflicts | ||
) { | ||
} | ||
|
||
public function jsonSerialize(): mixed | ||
{ | ||
return get_object_vars($this); | ||
} | ||
} |
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.