Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Adjust code to stricter Value Objects #3460

Merged
merged 1 commit into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Classes/ContentRepository/Service/WorkspaceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function getAllowedTargetWorkspaces(ContentRepository $contentRepository)
continue;
}
// Skip own personal workspace
if ($workspace->workspaceName->name === $this->userService->getPersonalWorkspaceName()) {
if ($workspace->workspaceName->value === $this->userService->getPersonalWorkspaceName()) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Changes/AbstractStructuralChange.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ protected function isNodeTypeAllowedAsChildNode(Node $node, NodeType $nodeType):
if (NodeInfoHelper::isAutoCreated($node, $subgraph)) {
$parentNode = $subgraph->findParentNode($node->nodeAggregateId);
return !$parentNode || $parentNode->nodeType->allowsGrandchildNodeType(
(string)$node->nodeName,
$node->nodeName->value,
$nodeType
);
} else {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Changes/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function apply(): void
$node = $subgraph->findNodeById($originalNodeAggregateId);
if (is_null($node)) {
throw new \InvalidArgumentException(
'Cannot apply Property on missing node ' . $originalNodeAggregateId,
'Cannot apply Property on missing node ' . $originalNodeAggregateId->value,
1645560836
);
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Changes/Remove.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function apply(): void
$parentNode = $this->findParentNode($subject);
if (is_null($parentNode)) {
throw new \InvalidArgumentException(
'Cannot apply Remove without a parent on node ' . $subject->nodeAggregateId,
'Cannot apply Remove without a parent on node ' . $subject->nodeAggregateId->value,
1645560717
);
}
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Model/Feedback/Operations/NodeCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getType(): string
*/
public function getDescription(): string
{
return sprintf('Document Node "%s" created.', (string)$this->getNode()->nodeAggregateId);
return sprintf('Document Node "%s" created.', $this->getNode()->nodeAggregateId->value);
}

/**
Expand Down Expand Up @@ -96,7 +96,7 @@ public function serializePayload(ControllerContext $controllerContext)
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
return [
'contextPath' => $nodeAddressFactory->createFromNode($node)->serializeForUri(),
'identifier' => (string)$node->nodeAggregateId,
'identifier' => $node->nodeAggregateId->value,
'isDocument' => $node->nodeType->isOfType(NodeTypeNameFactory::NAME_DOCUMENT)
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function getType(): string

public function getDescription(): string
{
return sprintf('Rendering of node "%s" required.', $this->node?->nodeAggregateId);
return sprintf('Rendering of node "%s" required.', $this->node?->nodeAggregateId->value);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function getType(): string

public function getDescription(): string
{
return sprintf('Updated info for node "%s" is available.', $this->node?->nodeAggregateId);
return sprintf('Updated info for node "%s" is available.', $this->node?->nodeAggregateId->value);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function isSimilarTo(FeedbackInterface $feedback)
return false;
}

return (string)$this->getWorkspaceName() === (string)$feedback->getWorkspaceName();
return $this->getWorkspaceName()?->value === $feedback->getWorkspaceName()?->value;
}

/**
Expand All @@ -120,12 +120,12 @@ public function serializePayload(ControllerContext $controllerContext)
$workspace = $contentRepository->getWorkspaceFinder()->findOneByName($this->workspaceName);

return $workspace ? [
'name' => (string)$this->workspaceName,
'name' => $this->workspaceName->value,
'publishableNodes' => $this->workspaceService->getPublishableNodeInfo(
$this->workspaceName,
$this->contentRepositoryId
),
'baseWorkspace' => (string)$workspace->baseWorkspaceName
'baseWorkspace' => $workspace->baseWorkspaceName->value
] : [];
}
}
2 changes: 1 addition & 1 deletion Classes/Domain/Service/NodePropertyConverterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private function toNodeIdentifierStrings(References $references): array
{
$identifiers = [];
foreach ($references as $reference) {
$identifiers[] = (string)$reference->node->nodeAggregateId;
$identifiers[] = $reference->node->nodeAggregateId->value;
}
return $identifiers;
}
Expand Down
16 changes: 8 additions & 8 deletions Classes/FlowQueryOperations/NeosUiDefaultNodesOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function evaluate(FlowQuery $flowQuery, array $arguments)
if ($currentNode) {
$currentNodePath = $subgraph->retrieveNodePath($currentNode->nodeAggregateId);
$siteNodePath = $subgraph->retrieveNodePath($siteNode->nodeAggregateId);
$parentNodeIsUnderneathSiteNode = str_starts_with((string)$currentNodePath, (string)$siteNodePath);
$parentNodeIsUnderneathSiteNode = str_starts_with($currentNodePath->value, $siteNodePath->value);
while ($currentNode instanceof Node
&& !$currentNode->nodeAggregateId->equals($siteNode->nodeAggregateId)
&& $parentNodeIsUnderneathSiteNode
Expand All @@ -96,7 +96,7 @@ public function evaluate(FlowQuery $flowQuery, array $arguments)
}

$nodes = [
((string)$siteNode->nodeAggregateId) => $siteNode
($siteNode->nodeAggregateId->value) => $siteNode
];

$gatherNodesRecursively = function (
Expand All @@ -120,29 +120,29 @@ public function evaluate(FlowQuery $flowQuery, array $arguments)
// load toggled nodes
in_array($baseNodeAddress->serializeForUri(), $toggledNodes) ||
// load children of all parents of documentNode
in_array((string)$baseNode->nodeAggregateId, $parents)
in_array($baseNode->nodeAggregateId->value, $parents)
) {
foreach ($subgraph->findChildNodes(
$baseNode->nodeAggregateId,
FindChildNodesFilter::nodeTypeConstraints($baseNodeTypeConstraints)
) as $childNode) {
$nodes[(string)$childNode->nodeAggregateId] = $childNode;
$nodes[$childNode->nodeAggregateId->value] = $childNode;
$gatherNodesRecursively($nodes, $childNode, $level + 1);
}
}
};
$gatherNodesRecursively($nodes, $siteNode);

if (!isset($nodes[(string)$documentNode->nodeAggregateId])) {
$nodes[(string)$documentNode->nodeAggregateId] = $documentNode;
if (!isset($nodes[$documentNode->nodeAggregateId->value])) {
$nodes[$documentNode->nodeAggregateId->value] = $documentNode;
}

foreach ($clipboardNodesContextPaths as $clipboardNodeContextPath) {
// TODO: does not work across multiple CRs yet.
$clipboardNodeAddress = $nodeAddressFactory->createFromUriString($clipboardNodeContextPath);
$clipboardNode = $subgraph->findNodeById($clipboardNodeAddress->nodeAggregateId);
if ($clipboardNode && !array_key_exists((string)$clipboardNode->nodeAggregateId, $nodes)) {
$nodes[(string)$clipboardNode->nodeAggregateId] = $clipboardNode;
if ($clipboardNode && !array_key_exists($clipboardNode->nodeAggregateId->value, $nodes)) {
$nodes[$clipboardNode->nodeAggregateId->value] = $clipboardNode;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ public function evaluate(FlowQuery $flowQuery, array $arguments)
$contextNode->nodeAggregateId,
FindChildNodesFilter::nodeTypeConstraints($arguments[0] ?? null)
) as $childNode) {
if (!isset($outputNodeIdentifiers[(string)$childNode->nodeAggregateId])) {
if (!isset($outputNodeIdentifiers[$childNode->nodeAggregateId->value])) {
$output[] = $childNode;
$outputNodeIdentifiers[(string)$childNode->nodeAggregateId] = true;
$outputNodeIdentifiers[$childNode->nodeAggregateId->value] = true;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Classes/Fusion/Helper/ContentDimensionsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function contentDimensionsByName(ContentRepositoryId $contentRepositoryId

$result = [];
foreach ($dimensions as $dimension) {
$result[(string)$dimension->id] = [
$result[$dimension->id->value] = [
'label' => $dimension->getConfigurationValue('label'),
'icon' => $dimension->getConfigurationValue('icon'),

Expand All @@ -53,7 +53,7 @@ public function contentDimensionsByName(ContentRepositoryId $contentRepositoryId

foreach ($dimension->values as $value) {
// TODO: make certain values hidable
$result[(string)$dimension->id]['presets'][$value->value] = [
$result[$dimension->id->value]['presets'][$value->value] = [
// TODO: name, uriSegment!
'values' => [$value->value],
'label' => $value->getConfigurationValue('label')
Expand Down
22 changes: 9 additions & 13 deletions Classes/Fusion/Helper/NodeInfoHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,14 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindChildNodesFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\Nodes;
use Neos\ContentRepository\Core\Projection\NodeHiddenState\NodeHiddenState;
use Neos\ContentRepository\Core\Projection\NodeHiddenState\NodeHiddenStateFinder;
use Neos\ContentRepository\Core\Projection\NodeHiddenState\NodeHiddenStateProjection;
use Neos\Neos\FrontendRouting\NodeAddress;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\ContentRepository\Core\NodeType\NodeTypeConstraintParser;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTypeConstraints;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Eel\ProtectedContextAwareInterface;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Flow\Persistence\PersistenceManagerInterface;
use Neos\Neos\FrontendRouting\NodeAddress;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\FrontendRouting\NodeUriBuilder;
use Neos\Neos\TypeConverter\EntityToIdentityConverter;
use Neos\Neos\Ui\Domain\Service\NodePropertyConverterService;
Expand Down Expand Up @@ -250,7 +246,7 @@ public static function isAutoCreated(Node $node, ContentSubgraphInterface $subgr
{
$parent = $subgraph->findParentNode($node->nodeAggregateId);
if ($parent) {
if (array_key_exists((string)$node->nodeName, $parent->nodeType->getAutoCreatedChildNodes())) {
if (array_key_exists($node->nodeName->value, $parent->nodeType->getAutoCreatedChildNodes())) {
return true;
}
}
Expand Down Expand Up @@ -328,15 +324,15 @@ public function renderNodesWithParents(array $nodes, ControllerContext $controll
$subgraph = $this->contentRepositoryRegistry->subgraphForNode($node);

$nodePath = $subgraph->retrieveNodePath($node->nodeAggregateId);
if (array_key_exists($nodePath->jsonSerialize(), $renderedNodes)) {
$renderedNodes[(string)$nodePath]['matched'] = true;
if (array_key_exists($nodePath->value, $renderedNodes)) {
$renderedNodes[$nodePath->value]['matched'] = true;
} elseif ($renderedNode = $this->renderNodeWithMinimalPropertiesAndChildrenInformation(
$node,
$controllerContext,
$baseNodeTypeOverride
)) {
$renderedNode['matched'] = true;
$renderedNodes[(string)$nodePath] = $renderedNode;
$renderedNodes[$nodePath->value] = $renderedNode;
} else {
continue;
}
Expand All @@ -350,8 +346,8 @@ public function renderNodesWithParents(array $nodes, ControllerContext $controll

$parentNodePath = $subgraph->retrieveNodePath($parentNode->nodeAggregateId);
while ($parentNode->nodeType->isOfType($baseNodeTypeOverride)) {
if (array_key_exists((string)$parentNodePath, $renderedNodes)) {
$renderedNodes[(string)$parentNodePath]['intermediate'] = true;
if (array_key_exists($parentNodePath->value, $renderedNodes)) {
$renderedNodes[$parentNodePath->value]['intermediate'] = true;
} else {
$renderedParentNode = $this->renderNodeWithMinimalPropertiesAndChildrenInformation(
$parentNode,
Expand All @@ -360,7 +356,7 @@ public function renderNodesWithParents(array $nodes, ControllerContext $controll
);
if ($renderedParentNode) {
$renderedParentNode['intermediate'] = true;
$renderedNodes[(string)$parentNodePath] = $renderedParentNode;
$renderedNodes[$parentNodePath->value] = $renderedParentNode;
}
}
$parentNode = $subgraph->findParentNode($parentNode->nodeAggregateId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function handle(CreateNodeAggregateWithNode $command, array $data, Conten

// otherwise, we fall back to the node name
if ($uriPathSegment === null && $command->nodeName !== null) {
$uriPathSegment = (string)$command->nodeName;
$uriPathSegment = $command->nodeName->value;
}

// if not empty, we transliterate the uriPathSegment according to the language of the new node
Expand Down