Skip to content

Commit

Permalink
Merge pull request #5080 from mhsdesign/task/5051-make-subgraph-not-j…
Browse files Browse the repository at this point in the history
…sonSerializeable

TASK: 5051 make subgraph not jsonSerializeable
  • Loading branch information
mhsdesign committed May 20, 2024
2 parents a20c7fd + d8663b9 commit 7bd219d
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -439,17 +439,6 @@ public function countNodes(): int
return $result;
}

/**
* @return array<string,mixed>
*/
public function jsonSerialize(): array
{
return [
'workspaceName' => $this->workspaceName,
'dimensionSpacePoint' => $this->dimensionSpacePoint,
];
}

/** ------------------------------------------- */

private function findNodeByPathFromStartingNode(NodePath $path, Node $startingNode): ?Node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,15 +539,4 @@ private function findNodeByPathFromStartingNode(NodePath $path, Node $startingNo
}
return $currentNode;
}

/**
* @return array<string,mixed>
*/
public function jsonSerialize(): array
{
return [
'workspaceName' => $this->workspaceName,
'dimensionSpacePoint' => $this->dimensionSpacePoint,
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,4 @@ private static function isFilterEmpty(object $filter): bool
{
return array_filter(get_object_vars($filter), static fn ($value) => $value !== null) === [];
}

/**
* @return array<string,mixed>
*/
public function jsonSerialize(): array
{
return $this->wrappedContentSubgraph->jsonSerialize();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
*
* @api
*/
interface ContentSubgraphInterface extends \JsonSerializable
interface ContentSubgraphInterface
{
public function getContentRepositoryId(): ContentRepositoryId;

Expand Down Expand Up @@ -203,10 +203,4 @@ public function retrieveNodePath(NodeAggregateId $nodeAggregateId): AbsoluteNode
* @internal this method might change without further notice.
*/
public function countNodes(): int;

/**
* @deprecated will be removed before Neos 9 release
* @return array<string,mixed>
*/
public function jsonSerialize(): array;
}
20 changes: 12 additions & 8 deletions Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,10 @@ public function render(): string
$resolvedNode = $subgraph->findNodeById($nodeAddress->nodeAggregateId);
if ($resolvedNode === null) {
$this->throwableStorage->logThrowable(new ViewHelperException(sprintf(
'Failed to resolve node "%s" on subgraph "%s"',
'Failed to resolve node "%s" in workspace "%s" and dimension %s',
$nodeAddress->nodeAggregateId->value,
json_encode($subgraph, JSON_PARTIAL_OUTPUT_ON_ERROR)
$subgraph->getWorkspaceName()->value,
$subgraph->getDimensionSpacePoint()->toJson()
), 1601372444));
}
if ($resolvedNode && $this->getNodeType($resolvedNode)->isOfType(NodeTypeNameFactory::NAME_SHORTCUT)) {
Expand All @@ -310,9 +311,10 @@ public function render(): string
}
} catch (NodeNotFoundException | InvalidShortcutException $e) {
$this->throwableStorage->logThrowable(new ViewHelperException(sprintf(
'Failed to resolve shortcut node "%s" on subgraph "%s"',
'Failed to resolve shortcut node "%s" in workspace "%s" and dimension %s',
$resolvedNode->aggregateId->value,
json_encode($subgraph, JSON_PARTIAL_OUTPUT_ON_ERROR)
$subgraph->getWorkspaceName()->value,
$subgraph->getDimensionSpacePoint()->toJson()
), 1601370239, $e));
}
}
Expand Down Expand Up @@ -384,9 +386,10 @@ private function resolveNodeAddressFromString(
$siteNode = $subgraph->findClosestNode($documentNodeAddress->nodeAggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_SITE));
if ($siteNode === null) {
throw new ViewHelperException(sprintf(
'Failed to determine site node for aggregate node "%s" and subgraph "%s"',
'Failed to determine site node for aggregate node "%s" in workspace "%s" and dimension %s',
$documentNodeAddress->nodeAggregateId->value,
json_encode($subgraph, JSON_PARTIAL_OUTPUT_ON_ERROR)
$subgraph->getWorkspaceName()->value,
$subgraph->getDimensionSpacePoint()->toJson()
), 1601366598);
}
if ($path === '~') {
Expand All @@ -405,10 +408,11 @@ private function resolveNodeAddressFromString(
}
if ($targetNode === null) {
throw new ViewHelperException(sprintf(
'Node on path "%s" could not be found for aggregate node "%s" and subgraph "%s"',
'Node on path "%s" could not be found for aggregate node "%s" in workspace "%s" and dimension %s',
$path,
$documentNodeAddress->nodeAggregateId->value,
json_encode($subgraph, JSON_PARTIAL_OUTPUT_ON_ERROR)
$subgraph->getWorkspaceName()->value,
$subgraph->getDimensionSpacePoint()->toJson()
), 1601311789);
}
return $documentNodeAddress->withNodeAggregateId($targetNode->aggregateId);
Expand Down
10 changes: 6 additions & 4 deletions Neos.Neos/Classes/ViewHelpers/Uri/NodeViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,10 @@ private function resolveNodeAddressFromString(string $path): ?NodeAddress
$siteNode = $subgraph->findClosestNode($documentNodeAddress->nodeAggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_SITE));
if ($siteNode === null) {
throw new ViewHelperException(sprintf(
'Failed to determine site node for aggregate node "%s" and subgraph "%s"',
'Failed to determine site node for aggregate node "%s" in workspace "%s" and dimension %s',
$documentNodeAddress->nodeAggregateId->value,
json_encode($subgraph, JSON_PARTIAL_OUTPUT_ON_ERROR)
$subgraph->getWorkspaceName()->value,
$subgraph->getDimensionSpacePoint()->toJson()
), 1601366598);
}
if ($path === '~') {
Expand All @@ -302,10 +303,11 @@ private function resolveNodeAddressFromString(string $path): ?NodeAddress
}
if ($targetNode === null) {
$this->throwableStorage->logThrowable(new ViewHelperException(sprintf(
'Node on path "%s" could not be found for aggregate node "%s" and subgraph "%s"',
'Node on path "%s" could not be found for aggregate node "%s" in workspace "%s" and dimension %s',
$path,
$documentNodeAddress->nodeAggregateId->value,
json_encode($subgraph, JSON_PARTIAL_OUTPUT_ON_ERROR)
$subgraph->getWorkspaceName()->value,
$subgraph->getDimensionSpacePoint()->toJson()
), 1601311789));
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function iExpectThisNodeToBeEnabled(): void
VisibilityConstraints::withoutRestrictions(),
);
$currentNode = $subgraph->findNodeById($this->currentNode->aggregateId);
Assert::assertNotNull($currentNode, sprintf('Failed to find node with id "%s" in subgraph %s', $this->currentNode->aggregateId->value, json_encode($subgraph)));
Assert::assertNotNull($currentNode, sprintf('Failed to find node with id "%s" in workspace %s and dimension %s', $this->currentNode->aggregateId->value, $subgraph->getWorkspaceName()->value, $subgraph->getDimensionSpacePoint()->toJson()));
Assert::assertFalse($currentNode->tags->contain(SubtreeTag::disabled()), sprintf('Node "%s" was expected to be enabled, but it is not', $this->currentNode->aggregateId->value));
}

Expand All @@ -78,7 +78,7 @@ public function iExpectThisNodeToBeDisabled(): void
VisibilityConstraints::withoutRestrictions(),
);
$currentNode = $subgraph->findNodeById($this->currentNode->aggregateId);
Assert::assertNotNull($currentNode, sprintf('Failed to find node with id "%s" in subgraph %s', $this->currentNode->aggregateId->value, json_encode($subgraph)));
Assert::assertNotNull($currentNode, sprintf('Failed to find node with id "%s" in workspace %s and dimension %s', $this->currentNode->aggregateId->value, $subgraph->getWorkspaceName()->value, $subgraph->getDimensionSpacePoint()->toJson()));
Assert::assertTrue($currentNode->tags->contain(SubtreeTag::disabled()), sprintf('Node "%s" was expected to be disabled, but it is not', $this->currentNode->aggregateId->value));
}

Expand Down

0 comments on commit 7bd219d

Please sign in to comment.