Skip to content

Commit

Permalink
Merge pull request #4739 from mhsdesign/task/4736-jsonSerialize-subgr…
Browse files Browse the repository at this point in the history
…aph-correctly

TASK: #4736 Json serialize Subgraph correctly
  • Loading branch information
mhsdesign authored Feb 7, 2024
2 parents dcb31c7 + 3a7aa79 commit 86582ef
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -461,15 +461,9 @@ public function countNodes(): int
}
}

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

/** ------------------------------------------- */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,14 +534,8 @@ private function getDatabaseConnection(): DatabaseConnection
return $this->databaseClient->getConnection();
}

/**
* @return array<string,mixed>
*/
public function jsonSerialize(): array
public function jsonSerialize(): ContentSubgraphIdentity
{
return [
'contentStreamId' => $this->contentStreamId,
'dimensionSpacePoint' => $this->dimensionSpacePoint
];
return $this->getIdentity();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
* @api
*/
final class ContentRepositoryId
final class ContentRepositoryId implements \JsonSerializable
{
private function __construct(
public readonly string $value
Expand Down Expand Up @@ -47,4 +47,9 @@ public function equals(self $other): bool
{
return $this->value === $other->value;
}

public function jsonSerialize(): mixed
{
return $this->value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ private static function isFilterEmpty(object $filter): bool
return array_filter(get_object_vars($filter), static fn ($value) => $value !== null) === [];
}

public function jsonSerialize(): mixed
public function jsonSerialize(): ContentSubgraphIdentity
{
return $this->wrappedContentSubgraph->jsonSerialize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*
* @api
*/
final class ContentSubgraphIdentity
final class ContentSubgraphIdentity implements \JsonSerializable
{
private function __construct(
public readonly ContentRepositoryId $contentRepositoryId,
Expand Down Expand Up @@ -90,4 +90,17 @@ public function withVisibilityConstraints(VisibilityConstraints $visibilityConst
$visibilityConstraints
);
}

/**
* @return array<string,mixed>
*/
public function jsonSerialize(): array
{
return [
'contentRepositoryId' => $this->contentRepositoryId,
'contentStreamId' => $this->contentStreamId,
'dimensionSpacePoint' => $this->dimensionSpacePoint,
'visibilityConstraints' => $this->visibilityConstraints
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,6 @@ public function retrieveNodePath(NodeAggregateId $nodeAggregateId): AbsoluteNode
* @internal this method might change without further notice.
*/
public function countNodes(): int;

public function jsonSerialize(): ContentSubgraphIdentity;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @api
*/
final class VisibilityConstraints
final class VisibilityConstraints implements \JsonSerializable
{
protected bool $disabledContentShown = false;

Expand Down Expand Up @@ -49,4 +49,9 @@ public static function frontend(): VisibilityConstraints
{
return new VisibilityConstraints(false);
}

public function jsonSerialize(): string
{
return $this->getHash();
}
}

0 comments on commit 86582ef

Please sign in to comment.