Skip to content

Commit

Permalink
TASK: Reintroduce usage of neos ui command value objects
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Sep 27, 2024
1 parent 8b4ed98 commit 71f8981
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#[Flow\Scope("singleton")]
final class ReloadNodesQueryHandler
{

#[Flow\Inject]
protected ContentRepositoryRegistry $contentRepositoryRegistry;

Expand Down
63 changes: 43 additions & 20 deletions Classes/Controller/BackendServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@
use Neos\Flow\Mvc\View\JsonView;
use Neos\Flow\Property\PropertyMapper;
use Neos\Flow\Security\Context;
use Neos\Neos\Domain\Service\WorkspaceNameBuilder;
use Neos\Neos\Domain\Service\WorkspacePublishingService;
use Neos\Neos\Domain\Service\WorkspaceService;
use Neos\Neos\FrontendRouting\NodeAddress;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult;
use Neos\Neos\Service\UserService;
use Neos\Neos\Ui\Application\ChangeTargetWorkspace;
use Neos\Neos\Ui\Application\DiscardAllChanges;
use Neos\Neos\Ui\Application\DiscardChangesInDocument;
use Neos\Neos\Ui\Application\DiscardChangesInSite;
use Neos\Neos\Ui\Application\PublishChangesInDocument;
use Neos\Neos\Ui\Application\PublishChangesInSite;
use Neos\Neos\Ui\Application\ReloadNodes\ReloadNodesQuery;
use Neos\Neos\Ui\Application\ReloadNodes\ReloadNodesQueryHandler;
use Neos\Neos\Ui\Application\SyncWorkspace\ConflictsOccurred;
Expand Down Expand Up @@ -202,14 +206,16 @@ public function publishChangesInSiteAction(array $command): void
try {
/** @todo send from UI */
$contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId;
$siteNodeAddress = $this->nodeService->deserializeNodeAddress(
$command['contentRepositoryId'] = $contentRepositoryId->value;
$command['siteId'] = $this->nodeService->deserializeNodeAddress(
$command['siteId'],
$contentRepositoryId
);
)->nodeAggregateId->value;
$command = PublishChangesInSite::fromArray($command);
$publishingResult = $this->workspacePublishingService->publishChangesInSite(
$contentRepositoryId,
$siteNodeAddress->workspaceName,
$siteNodeAddress->nodeAggregateId,
$command->contentRepositoryId,
$command->workspaceName,
$command->siteId,
);
$this->view->assign('value', [
'success' => [
Expand Down Expand Up @@ -239,15 +245,18 @@ public function publishChangesInDocumentAction(array $command): void
try {
/** @todo send from UI */
$contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId;
$documentNodeAddress = $this->nodeService->deserializeNodeAddress(
$command['contentRepositoryId'] = $contentRepositoryId->value;
$command['documentId'] = $this->nodeService->deserializeNodeAddress(
$command['documentId'],
$contentRepositoryId
);
)->nodeAggregateId->value;
$command = PublishChangesInDocument::fromArray($command);

try {
$publishingResult = $this->workspacePublishingService->publishChangesInDocument(
$contentRepositoryId,
$documentNodeAddress->workspaceName,
$documentNodeAddress->nodeAggregateId,
$command->contentRepositoryId,
$command->workspaceName,
$command->documentId,
);

$this->view->assign('value', [
Expand Down Expand Up @@ -291,9 +300,14 @@ public function discardAllChangesAction(array $command): void
try {
/** @todo send from UI */
$contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId;
$workspaceName = WorkspaceName::fromString($command['workspaceName']);
$command['contentRepositoryId'] = $contentRepositoryId->value;
$command = DiscardAllChanges::fromArray($command);

$discardingResult = $this->workspacePublishingService->discardAllWorkspaceChanges(
$command->contentRepositoryId,
$command->workspaceName
);

$discardingResult = $this->workspacePublishingService->discardAllWorkspaceChanges($contentRepositoryId, $workspaceName);
$this->view->assign('value', [
'success' => [
'numberOfAffectedChanges' => $discardingResult->numberOfDiscardedChanges
Expand Down Expand Up @@ -321,15 +335,17 @@ public function discardChangesInSiteAction(array $command): void
try {
/** @todo send from UI */
$contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId;
$siteNodeAddress = $this->nodeService->deserializeNodeAddress(
$command['contentRepositoryId'] = $contentRepositoryId->value;
$command['siteId'] = $this->nodeService->deserializeNodeAddress(
$command['siteId'],
$contentRepositoryId
);
)->nodeAggregateId->value;
$command = DiscardChangesInSite::fromArray($command);

$discardingResult = $this->workspacePublishingService->discardChangesInSite(
$contentRepositoryId,
$siteNodeAddress->workspaceName,
$siteNodeAddress->nodeAggregateId
$command->contentRepositoryId,
$command->workspaceName,
$command->siteId
);

$this->view->assign('value', [
Expand Down Expand Up @@ -359,11 +375,18 @@ public function discardChangesInDocumentAction(array $command): void
try {
/** @todo send from UI */
$contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId;
$documentNodeAddress = $this->nodeService->deserializeNodeAddress(
$command['contentRepositoryId'] = $contentRepositoryId->value;
$command['documentId'] = $this->nodeService->deserializeNodeAddress(
$command['documentId'],
$contentRepositoryId
)->nodeAggregateId->value;
$command = DiscardChangesInDocument::fromArray($command);

$discardingResult = $this->workspacePublishingService->discardChangesInDocument(
$command->contentRepositoryId,
$command->workspaceName,
$command->documentId
);
$discardingResult = $this->workspacePublishingService->discardChangesInDocument($contentRepositoryId, $documentNodeAddress->workspaceName, $documentNodeAddress->nodeAggregateId);

$this->view->assign('value', [
'success' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ public function getConfiguration(
];
}

/**
* @return array<string,array{name:string,title:string,readonly:bool}>
*/
private function getAllowedTargetWorkspaces(ContentRepository $contentRepository): array
{
$backendUser = $this->userService->getBackendUser();
Expand Down

0 comments on commit 71f8981

Please sign in to comment.