Skip to content

Commit

Permalink
Merge pull request #19 from haase-fabian/fix-updatePath
Browse files Browse the repository at this point in the history
BUGFIX: Use UpdateNodePath feedback when moving node
  • Loading branch information
daniellienert authored Feb 20, 2024
2 parents e27b48e + 71939da commit cc1bec2
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Classes/Archivist.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\Flow\Log\ThrowableStorageInterface;
use Neos\Flow\Log\Utility\LogEnvironment;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\NodeCreated;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\UpdateNodeInfo;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\UpdateNodePath;
use Neos\Neos\Ui\Domain\Model\FeedbackCollection;
use Psr\Log\LoggerInterface;
use PunktDe\Archivist\Exception\ArchivistConfigurationException;
Expand Down Expand Up @@ -135,12 +135,14 @@ public function organizeNode(NodeInterface $triggeringNode, array $sortingInstru
$hierarchyNode = $this->hierarchyService->buildHierarchy($sortingInstructions['hierarchy'], $context, $sortingInstructions['publishHierarchy'] ?? false);

if ($hierarchyNode !== $affectedNode->getParent() && $hierarchyNode->getNode($affectedNode->getName()) === null) {

$this->affectedNodeStorage->addNode($affectedNode);

$oldContextPath = $affectedNode->getContextPath();
$affectedNode->moveInto($hierarchyNode);
$this->organizedNodeParents[$affectedNode->getIdentifier()] = $affectedNode->getParent();
$newContextPath = $affectedNode->getContextPath();

$this->sendNodeMovedFeedback($affectedNode, $hierarchyNode);
$this->sendNodeMovedFeedback($hierarchyNode, $affectedNode, $oldContextPath, $newContextPath);

$this->logger->info(sprintf('Moved affected node %s to path %s', $affectedNode->getNodeType()->getName(), $affectedNode->getPath()), LogEnvironment::fromMethodName(__METHOD__));
}
Expand Down Expand Up @@ -259,22 +261,25 @@ protected function buildCustomContext(array $baseContext, array $contextConfigur
}

/**
* @param NodeInterface $affectedNode
* @param NodeInterface $hierarchyNode
* @param NodeInterface $affectedNode
* @param string $oldContextPath
* @param string $newContextPath
*/
private function sendNodeMovedFeedback(NodeInterface $affectedNode, NodeInterface $hierarchyNode): void
private function sendNodeMovedFeedback(NodeInterface $hierarchyNode, NodeInterface $affectedNode, string $oldContextPath, string $newContextPath): void
{
$created = new NodeCreated();
$created->setNode($affectedNode);
$this->feedbackCollection->add($created);

$updateNodeInfo = new UpdateNodeInfo();
$updateNodeInfo->setNode($hierarchyNode);
$this->feedbackCollection->add($updateNodeInfo);

$updateNodeInfo = new UpdateNodeInfo();
$updateNodeInfo->setNode($affectedNode);
$this->feedbackCollection->add($updateNodeInfo);

$updateNodePath = new UpdateNodePath();
$updateNodePath->setOldContextPath($oldContextPath);
$updateNodePath->setNewContextPath($newContextPath);
$this->feedbackCollection->add($updateNodePath);
}
}

Expand Down

0 comments on commit cc1bec2

Please sign in to comment.