Skip to content

Commit

Permalink
TASK: Rename to NeosUiNodeService::getNodeFromContextPath
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Oct 12, 2023
1 parent 0c85b4a commit 7a0cde7
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,20 @@
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;

/**
* @internal
* @Flow\Scope("singleton")
*/
class NodeService
class NeosUiNodeService
{
use NodeTypeWithFallbackProvider;

#[Flow\Inject]
protected ContentRepositoryRegistry $contentRepositoryRegistry;

/**
* Converts a given context path to a node object
*/
public function getNodeFromContextPath(string $contextPath, ContentRepositoryId $contentRepositoryId): ?Node
public function findNodeBySerializedNodeAddress(string $serializedNodeAddress, ContentRepositoryId $contentRepositoryId): ?Node
{
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
$nodeAddress = NodeAddressFactory::create($contentRepository)->createFromUriString($contextPath);
$nodeAddress = NodeAddressFactory::create($contentRepository)->createFromUriString($serializedNodeAddress);

$subgraph = $contentRepository->getContentGraph()->getSubgraph(
$nodeAddress->contentStreamId,
Expand Down
6 changes: 3 additions & 3 deletions Classes/Controller/BackendServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult;
use Neos\Neos\Service\UserService;
use Neos\Neos\Ui\ContentRepository\Service\NodeService;
use Neos\Neos\Ui\ContentRepository\Service\NeosUiNodeService;
use Neos\Neos\Ui\ContentRepository\Service\WorkspaceService;
use Neos\Neos\Ui\Domain\Model\ChangeCollection;
use Neos\Neos\Ui\Domain\Model\Feedback\Messages\Error;
Expand Down Expand Up @@ -88,7 +88,7 @@ class BackendServiceController extends ActionController

/**
* @Flow\Inject
* @var NodeService
* @var NeosUiNodeService
*/
protected $nodeService;

Expand Down Expand Up @@ -590,7 +590,7 @@ public function flowQueryAction(array $chain): string
/** @var array<int,mixed> $payload */
$payload = $createContext['payload'] ?? [];
$flowQuery = new FlowQuery(array_map(
fn ($envelope) => $this->nodeService->getNodeFromContextPath($envelope['$node'], $contentRepositoryId),
fn ($envelope) => $this->nodeService->findNodeBySerializedNodeAddress($envelope['$node'], $contentRepositoryId),
$payload
));

Expand Down
6 changes: 3 additions & 3 deletions Classes/Domain/Model/Changes/AbstractStructuralChange.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\Nodes;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Ui\ContentRepository\Service\NodeService;
use Neos\Neos\Ui\ContentRepository\Service\NeosUiNodeService;
use Neos\Neos\Ui\Domain\Model\AbstractChange;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\ReloadDocument;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\RenderContentOutOfBand;
Expand Down Expand Up @@ -50,7 +50,7 @@ abstract class AbstractStructuralChange extends AbstractChange

/**
* @Flow\Inject
* @var NodeService
* @var NeosUiNodeService
*/
protected $nodeService;

Expand Down Expand Up @@ -111,7 +111,7 @@ public function getSiblingNode(): ?Node
}

if ($this->cachedSiblingNode === null) {
$this->cachedSiblingNode = $this->nodeService->getNodeFromContextPath(
$this->cachedSiblingNode = $this->nodeService->findNodeBySerializedNodeAddress(
$this->siblingDomAddress->getContextPath(),
$this->getSubject()->subgraphIdentity->contentRepositoryId
);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Changes/CopyInto.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function getParentNode(): ?Node
{
if (!isset($this->cachedParentNode)) {
$this->cachedParentNode = $this->parentContextPath
? $this->nodeService->getNodeFromContextPath($this->parentContextPath, $this->getSubject()->subgraphIdentity->contentRepositoryId)
? $this->nodeService->findNodeBySerializedNodeAddress($this->parentContextPath, $this->getSubject()->subgraphIdentity->contentRepositoryId)
: null;
}

Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Changes/MoveInto.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getParentNode(): ?Node
return null;
}

return $this->nodeService->getNodeFromContextPath(
return $this->nodeService->findNodeBySerializedNodeAddress(
$this->parentContextPath,
$this->getSubject()->subgraphIdentity->contentRepositoryId
);
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Service/NodeTreeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Neos\Service\LinkingService;
use Neos\Neos\Ui\ContentRepository\Service\NodeService;
use Neos\Neos\Ui\ContentRepository\Service\NeosUiNodeService;

class NodeTreeBuilder
{
Expand Down Expand Up @@ -58,7 +58,7 @@ class NodeTreeBuilder

/**
* @Flow\Inject
* @var NodeService
* @var NeosUiNodeService
*/
protected $nodeService;

Expand Down
8 changes: 4 additions & 4 deletions Classes/TypeConverter/ChangeCollectionConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Neos\Flow\Property\PropertyMappingConfigurationInterface;
use Neos\Flow\Property\TypeConverter\AbstractTypeConverter;
use Neos\Flow\Reflection\ReflectionService;
use Neos\Neos\Ui\ContentRepository\Service\NodeService;
use Neos\Neos\Ui\ContentRepository\Service\NeosUiNodeService;
use Neos\Neos\Ui\Domain\Model\ChangeCollection;
use Neos\Neos\Ui\Domain\Model\ChangeInterface;
use Neos\Neos\Ui\Domain\Model\Changes\Property;
Expand Down Expand Up @@ -76,7 +76,7 @@ class ChangeCollectionConverter

/**
* @Flow\Inject
* @var NodeService
* @var NeosUiNodeService
*/
protected $nodeService;

Expand Down Expand Up @@ -141,7 +141,7 @@ protected function convertChangeData(array $changeData, ContentRepositoryId $con


$subjectContextPath = $changeData['subject'];
$subject = $this->nodeService->getNodeFromContextPath($subjectContextPath, $contentRepositoryId);
$subject = $this->nodeService->findNodeBySerializedNodeAddress($subjectContextPath, $contentRepositoryId);
if (is_null($subject)) {
throw new \RuntimeException('Could not find node for subject "' . $subjectContextPath . '"', 1645657340);
}
Expand All @@ -150,7 +150,7 @@ protected function convertChangeData(array $changeData, ContentRepositoryId $con

if (isset($changeData['reference']) && method_exists($changeClassInstance, 'setReference')) {
$referenceContextPath = $changeData['reference'];
$reference = $this->nodeService->getNodeFromContextPath($referenceContextPath, $contentRepositoryId);
$reference = $this->nodeService->findNodeBySerializedNodeAddress($referenceContextPath, $contentRepositoryId);
$changeClassInstance->setReference($reference);
}

Expand Down

0 comments on commit 7a0cde7

Please sign in to comment.