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: Remove magic __toString methods from Value Objects #4156

Merged
merged 26 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
31cb00a
!!! TASK: Remove magic __toString methods from Value Objects
bwaidelich Apr 1, 2023
fa97f6e
Adjust some more VOs
bwaidelich Apr 1, 2023
88cb1fd
Replace code using Value Objects
bwaidelich Apr 1, 2023
3fbf9fd
Fix more usages
bwaidelich Apr 1, 2023
cfe3bdc
Merge branch '9.0' into feature/4133-stricter-value-objects
bwaidelich Apr 2, 2023
2ee183d
Fix more usages
bwaidelich Apr 2, 2023
6c64a93
Fix more usages
bwaidelich Apr 3, 2023
b072685
Adjust code to nullable types
bwaidelich Apr 3, 2023
6a311ec
Merge branch '9.0' into feature/4133-stricter-value-objects
bwaidelich Apr 3, 2023
08271b2
Merge branch '9.0' into feature/4133-stricter-value-objects
bwaidelich Apr 3, 2023
94e0d40
Merge branch '9.0' into feature/4133-stricter-value-objects
bwaidelich Apr 3, 2023
869770b
Merge branch '9.0' into feature/4133-stricter-value-objects
bwaidelich Apr 3, 2023
d6bdceb
Fix more usages
bwaidelich Apr 3, 2023
bb55e5f
Fix more usages
bwaidelich Apr 3, 2023
df23509
Fix more usages
bwaidelich Apr 3, 2023
e972ebe
Fix more usages
bwaidelich Apr 3, 2023
0e505d7
Merge branch '9.0' into feature/4133-stricter-value-objects
bwaidelich Apr 3, 2023
e3ae60e
Fix linting errors
bwaidelich Apr 3, 2023
d9f9181
Fix more usages
bwaidelich Apr 3, 2023
16bfe34
Fix more usages
bwaidelich Apr 3, 2023
ca85043
Fix more usages
bwaidelich Apr 3, 2023
b28bcdc
Fix more usages
bwaidelich Apr 3, 2023
bbac395
Merge branch '9.0' into feature/4133-stricter-value-objects
ahaeslich Apr 10, 2023
39aad82
TASK: Fix usages from pull request `Rework asset usage for current st…
ahaeslich Apr 10, 2023
a7f9e68
TASK: Fix some usages in workspace backend module
ahaeslich Apr 10, 2023
514730f
TASK: Fix styling
ahaeslich Apr 10, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private function transformDatasetToHierarchyRelationRecord(array $dataset): arra

return [
'contentstreamid' => $dataset['contentStreamId'],
'dimensionspacepoint' => \json_encode($dimensionSpacePoint),
'dimensionspacepoint' => $dimensionSpacePoint->toJson(),
'dimensionspacepointhash' => $dimensionSpacePoint->hash,
'parentnodeanchor' => $parentNodeAggregateId->isNonExistent()
? Algorithms::generateUUID()
Expand Down Expand Up @@ -271,9 +271,9 @@ private function findRelationAnchorPointByIds(
AND h.contentstreamid = :contentStreamId
AND h.dimensionspacepointhash = :dimensionSpacePointHash',
[
'contentStreamId' => (string)$contentStreamId,
'contentStreamId' => $contentStreamId->value,
'dimensionSpacePointHash' => $dimensionSpacePoint->hash,
'nodeAggregateId' => (string)$nodeAggregateId
'nodeAggregateId' => $nodeAggregateId->value
]
)->fetchAssociative();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use Neos\ContentRepository\Core\Feature\NodeDisabling\Event\NodeAggregateWasEnabled;
use Neos\ContentRepository\Core\Feature\NodeModification\Event\NodePropertiesWereSet;
use Neos\ContentRepository\Core\Feature\NodeMove\Event\NodeAggregateWasMoved;
use Neos\ContentRepository\Core\Feature\NodeReferencing\Dto\SerializedNodeReference;
use Neos\ContentRepository\Core\Feature\NodeReferencing\Event\NodeReferencesWereSet;
use Neos\ContentRepository\Core\Feature\NodeRemoval\Event\NodeAggregateWasRemoved;
use Neos\ContentRepository\Core\Feature\NodeRenaming\Event\NodeAggregateNameWasChanged;
Expand Down Expand Up @@ -336,9 +337,9 @@ private function whenRootNodeAggregateDimensionsWereUpdated(RootNodeAggregateDim
AND childnodeanchor = :childNodeAnchor
AND contentstreamid = :contentStreamId
', [
'parentNodeAnchor' => (string)NodeRelationAnchorPoint::forRootEdge(),
'childNodeAnchor' => (string)$rootNodeAnchorPoint,
'contentStreamId' => (string)$event->contentStreamId
'parentNodeAnchor' => NodeRelationAnchorPoint::forRootEdge()->value,
'childNodeAnchor' => $rootNodeAnchorPoint->value,
'contentStreamId' => $event->contentStreamId->value,
]);
// recreate hierarchy edges for the root node
$this->connectHierarchy(
Expand Down Expand Up @@ -399,9 +400,9 @@ private function whenNodeAggregateNameWasChanged(NodeAggregateNameWasChanged $ev
n.nodeaggregateid = :nodeAggregateId
and h.contentstreamid = :contentStreamId
', [
'newName' => (string)$event->newNodeName,
'nodeAggregateId' => (string)$event->nodeAggregateId,
'contentStreamId' => (string)$event->contentStreamId,
'newName' => $event->newNodeName->value,
'nodeAggregateId' => $event->nodeAggregateId->value,
'contentStreamId' => $event->contentStreamId->value,
'lastModified' => $eventEnvelope->recordedAt,
'originalLastModified' => self::initiatingDateTime($eventEnvelope),
], [
Expand Down Expand Up @@ -435,18 +436,18 @@ private function connectRestrictionRelationsFromParentNodeToNewlyCreatedNode(
r.contentstreamid,
r.dimensionspacepointhash,
r.originnodeaggregateid,
"' . $newlyCreatedNodeAggregateId . '" as affectednodeaggregateid
"' . $newlyCreatedNodeAggregateId->value . '" as affectednodeaggregateid
FROM
' . $this->tableNamePrefix . '_restrictionrelation r
WHERE
r.contentstreamid = :sourceContentStreamId
and r.dimensionspacepointhash IN (:visibleDimensionSpacePoints)
and r.affectednodeaggregateid = :parentNodeAggregateId
', [
'sourceContentStreamId' => (string)$contentStreamId,
'sourceContentStreamId' => $contentStreamId->value,
'visibleDimensionSpacePoints' => $dimensionSpacePointsInWhichNewlyCreatedNodeAggregateIsVisible
->getPointHashes(),
'parentNodeAggregateId' => (string)$parentNodeAggregateId
'parentNodeAggregateId' => $parentNodeAggregateId->value
], [
'visibleDimensionSpacePoints' => Connection::PARAM_STR_ARRAY
]);
Expand Down Expand Up @@ -641,7 +642,7 @@ private function getRelationPositionAfterRecalculation(
$offset += self::RELATION_DEFAULT_OFFSET;
if (
$succeedingSiblingAnchorPoint
&& (string)$relation->childNodeAnchor === (string)$succeedingSiblingAnchorPoint
&& $relation->childNodeAnchor->equals($succeedingSiblingAnchorPoint)
) {
$position = $offset;
$offset += self::RELATION_DEFAULT_OFFSET;
Expand Down Expand Up @@ -679,12 +680,12 @@ private function whenContentStreamWasForked(ContentStreamWasForked $event): void
h.position,
h.dimensionspacepoint,
h.dimensionspacepointhash,
"' . $event->newContentStreamId . '" AS contentstreamid
"' . $event->newContentStreamId->value . '" AS contentstreamid
FROM
' . $this->tableNamePrefix . '_hierarchyrelation h
WHERE h.contentstreamid = :sourceContentStreamId
', [
'sourceContentStreamId' => (string)$event->sourceContentStreamId
'sourceContentStreamId' => $event->sourceContentStreamId->value
]);

//
Expand All @@ -698,15 +699,15 @@ private function whenContentStreamWasForked(ContentStreamWasForked $event): void
affectednodeaggregateid
)
SELECT
"' . $event->newContentStreamId . '" AS contentstreamid,
"' . $event->newContentStreamId->value . '" AS contentstreamid,
r.dimensionspacepointhash,
r.originnodeaggregateid,
r.affectednodeaggregateid
FROM
' . $this->tableNamePrefix . '_restrictionrelation r
WHERE r.contentstreamid = :sourceContentStreamId
', [
'sourceContentStreamId' => (string)$event->sourceContentStreamId
'sourceContentStreamId' => $event->sourceContentStreamId->value
]);

// NOTE: as reference edges are attached to Relation Anchor Points (and they are lazily copy-on-written),
Expand All @@ -724,7 +725,7 @@ private function whenContentStreamWasRemoved(ContentStreamWasRemoved $event): vo
WHERE
contentstreamid = :contentStreamId
', [
'contentStreamId' => (string)$event->contentStreamId
'contentStreamId' => $event->contentStreamId->value
]);

// Drop non-referenced nodes (which do not have a hierarchy relation anymore)
Expand Down Expand Up @@ -755,7 +756,7 @@ private function whenContentStreamWasRemoved(ContentStreamWasRemoved $event): vo
WHERE
contentstreamid = :contentStreamId
', [
'contentStreamId' => (string)$event->contentStreamId
'contentStreamId' => $event->contentStreamId->value
]);
});
}
Expand All @@ -775,8 +776,8 @@ private function whenNodePropertiesWereSet(NodePropertiesWereSet $event, EventEn
if (is_null($anchorPoint)) {
throw new \InvalidArgumentException(
'Cannot update node with copy on write since no anchor point could be resolved for node '
. $event->getNodeAggregateId() . ' in content stream '
. $event->getContentStreamId(),
. $event->getNodeAggregateId()->value . ' in content stream '
. $event->getContentStreamId()->value,
1645303332
);
}
Expand Down Expand Up @@ -812,8 +813,8 @@ private function whenNodeReferencesWereSet(NodeReferencesWereSet $event, EventEn
throw new \InvalidArgumentException(
'Could not apply event of type "' . get_class($event)
. '" since no anchor point could be resolved for node '
. $event->getNodeAggregateId() . ' in content stream '
. $event->getContentStreamId(),
. $event->getNodeAggregateId()->value . ' in content stream '
. $event->getContentStreamId()->value,
1658580583
);
}
Expand All @@ -838,18 +839,19 @@ function (NodeRecord $node) use ($eventEnvelope) {

// remove old
$this->getDatabaseConnection()->delete($this->tableNamePrefix . '_referencerelation', [
'nodeanchorpoint' => $nodeAnchorPoint,
'name' => $event->referenceName
'nodeanchorpoint' => $nodeAnchorPoint?->value,
'name' => $event->referenceName->value
]);

// set new
$position = 0;
/** @var SerializedNodeReference $reference */
foreach ($event->references as $reference) {
$this->getDatabaseConnection()->insert($this->tableNamePrefix . '_referencerelation', [
'name' => $event->referenceName,
'name' => $event->referenceName->value,
'position' => $position,
'nodeanchorpoint' => $nodeAnchorPoint,
'destinationnodeaggregateid' => $reference->targetNodeAggregateId,
'nodeanchorpoint' => $nodeAnchorPoint?->value,
'destinationnodeaggregateid' => $reference->targetNodeAggregateId->value,
'properties' => $reference->properties
? \json_encode($reference->properties, JSON_THROW_ON_ERROR)
: null
Expand Down Expand Up @@ -917,7 +919,7 @@ private function cascadeRestrictionRelations(
-- create new restriction relations...
-- --------------------------------
SELECT
"' . (string)$contentStreamId . '" as contentstreamid,
"' . $contentStreamId->value . '" as contentstreamid,
tree.dimensionspacepointhash,
originnodeaggregateid,
tree.nodeaggregateid as affectednodeaggregateid
Expand All @@ -933,9 +935,9 @@ private function cascadeRestrictionRelations(
) AS joinedrestrictingancestors
',
[
'contentStreamId' => (string)$contentStreamId,
'parentNodeAggregateId' => (string)$parentNodeAggregateId,
'entryNodeAggregateId' => (string)$entryNodeAggregateId,
'contentStreamId' => $contentStreamId->value,
'parentNodeAggregateId' => $parentNodeAggregateId->value,
'entryNodeAggregateId' => $entryNodeAggregateId->value,
'dimensionSpacePointHashes' => $affectedDimensionSpacePoints->getPointHashes(),
'affectedDimensionSpacePointHashes' => $affectedDimensionSpacePoints->getPointHashes()
],
Expand Down Expand Up @@ -1008,7 +1010,7 @@ protected function copyNodeToDimensionSpacePoint(
$copy = new NodeRecord(
$copyRelationAnchorPoint,
$sourceNode->nodeAggregateId,
$originDimensionSpacePoint->jsonSerialize(),
$originDimensionSpacePoint->coordinates,
$originDimensionSpacePoint->hash,
$sourceNode->properties,
$sourceNode->nodeTypeName,
Expand Down Expand Up @@ -1082,9 +1084,9 @@ private function updateNodeRecordWithCopyOnWrite(
:originalNodeAnchor IN (h.childnodeanchor, h.parentnodeanchor)
AND h.contentstreamid = :contentStreamId',
[
'newNodeAnchor' => (string)$copiedNode->relationAnchorPoint,
'originalNodeAnchor' => (string)$anchorPoint,
'contentStreamId' => (string)$contentStreamIdWhereWriteOccurs
'newNodeAnchor' => $copiedNode->relationAnchorPoint->value,
'originalNodeAnchor' => $anchorPoint->value,
'contentStreamId' => $contentStreamIdWhereWriteOccurs->value,
]
);

Expand Down Expand Up @@ -1128,8 +1130,8 @@ private function copyReferenceRelations(
' . $this->tableNamePrefix . '_referencerelation ref
WHERE ref.nodeanchorpoint = :sourceNodeAnchorPoint
', [
'sourceNodeAnchorPoint' => (string)$sourceRelationAnchorPoint,
'destinationRelationAnchorPoint' => (string)$destinationRelationAnchorPoint
'sourceNodeAnchorPoint' => $sourceRelationAnchorPoint->value,
'destinationRelationAnchorPoint' => $destinationRelationAnchorPoint->value
]);
}

Expand All @@ -1154,7 +1156,7 @@ private function whenDimensionSpacePointWasMoved(DimensionSpacePointWasMoved $ev
',
[
'dimensionSpacePointHash' => $event->source->hash,
'contentStreamId' => (string)$event->contentStreamId
'contentStreamId' => $event->contentStreamId->value
]
);
while ($res = $rel->fetchAssociative()) {
Expand All @@ -1163,7 +1165,7 @@ private function whenDimensionSpacePointWasMoved(DimensionSpacePointWasMoved $ev
$event->contentStreamId,
$relationAnchorPoint,
function (NodeRecord $nodeRecord) use ($event) {
$nodeRecord->originDimensionSpacePoint = $event->target->jsonSerialize();
$nodeRecord->originDimensionSpacePoint = $event->target->coordinates;
$nodeRecord->originDimensionSpacePointHash = $event->target->hash;
}
);
Expand All @@ -1183,8 +1185,8 @@ function (NodeRecord $nodeRecord) use ($event) {
[
'originalDimensionSpacePointHash' => $event->source->hash,
'newDimensionSpacePointHash' => $event->target->hash,
'newDimensionSpacePoint' => json_encode($event->target->jsonSerialize()),
'contentStreamId' => (string)$event->contentStreamId
'newDimensionSpacePoint' => $event->target->toJson(),
'contentStreamId' => $event->contentStreamId->value
]
);

Expand All @@ -1201,7 +1203,7 @@ function (NodeRecord $nodeRecord) use ($event) {
[
'originalDimensionSpacePointHash' => $event->source->hash,
'newDimensionSpacePointHash' => $event->target->hash,
'contentStreamId' => (string)$event->contentStreamId
'contentStreamId' => $event->contentStreamId->value
]
);
});
Expand Down Expand Up @@ -1235,10 +1237,10 @@ private function whenDimensionShineThroughWasAdded(DimensionShineThroughWasAdded
WHERE h.contentstreamid = :contentStreamId
AND h.dimensionspacepointhash = :sourceDimensionSpacePointHash',
[
'contentStreamId' => $event->contentStreamId->jsonSerialize(),
'contentStreamId' => $event->contentStreamId->value,
'sourceDimensionSpacePointHash' => $event->source->hash,
'newDimensionSpacePointHash' => $event->target->hash,
'newDimensionSpacePoint' => json_encode($event->target->jsonSerialize()),
'newDimensionSpacePoint' => $event->target->toJson(),
]
);

Expand All @@ -1261,7 +1263,7 @@ private function whenDimensionShineThroughWasAdded(DimensionShineThroughWasAdded
AND r.dimensionspacepointhash = :sourceDimensionSpacePointHash

', [
'contentStreamId' => (string)$event->contentStreamId,
'contentStreamId' => $event->contentStreamId->value,
'sourceDimensionSpacePointHash' => $event->source->hash,
'targetDimensionSpacePointHash' => $event->target->hash
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(
public static function graphProjectionTableNamePrefix(
ContentRepositoryId $contentRepositoryId
): string {
return sprintf('cr_%s_p_graph', $contentRepositoryId);
return sprintf('cr_%s_p_graph', $contentRepositoryId->value);
}

public function build(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ private function whenNodeAggregateWasDisabled(NodeAggregateWasDisabled $event):
)

select
"' . $event->contentStreamId . '" as contentstreamid,
"' . $event->contentStreamId->value . '" as contentstreamid,
dimensionspacepointhash,
"' . $event->nodeAggregateId . '" as originnodeaggregateid,
"' . $event->nodeAggregateId->value . '" as originnodeaggregateid,
nodeaggregateid as affectednodeaggregateid
from tree
',
[
'entryNodeAggregateId' => (string)$event->nodeAggregateId,
'contentStreamId' => (string)$event->contentStreamId,
'entryNodeAggregateId' => $event->nodeAggregateId->value,
'contentStreamId' => $event->contentStreamId->value,
'dimensionSpacePointHashes' => $event->affectedDimensionSpacePoints->getPointHashes()
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected function removeRelationRecursivelyFromDatabaseIncludingNonReferencedNo
AND h.contentstreamid IS NULL
',
[
'anchorPointForNode' => (string)$ingoingRelation->childNodeAnchor,
'anchorPointForNode' => $ingoingRelation->childNodeAnchor->value,
]
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ private function removeOutgoingRestrictionRelationsOfNodeAggregateInDimensionSpa
AND r.originnodeaggregateid = :originNodeAggregateId
AND r.dimensionspacepointhash in (:dimensionSpacePointHashes)',
[
'contentStreamId' => (string)$contentStreamId,
'originNodeAggregateId' => (string)$originNodeAggregateId,
'contentStreamId' => $contentStreamId->value,
'originNodeAggregateId' => $originNodeAggregateId->value,
'dimensionSpacePointHashes' => $affectedDimensionSpacePoints->getPointHashes()
],
[
Expand Down Expand Up @@ -111,8 +111,8 @@ private function removeAllRestrictionRelationsUnderneathNodeAggregate(
and r.affectednodeaggregateid = tree.nodeaggregateid
',
[
'entryNodeAggregateId' => (string)$nodeAggregateId,
'contentStreamId' => (string)$contentStreamId,
'entryNodeAggregateId' => $nodeAggregateId->value,
'contentStreamId' => $contentStreamId->value,
]
);
}
Expand Down Expand Up @@ -143,7 +143,7 @@ private function removeAllRestrictionRelationsInSubtreeImposedByAncestors(
AND r.affectednodeaggregateid IN (:descendantNodeAggregateIds)
AND r.dimensionspacepointhash IN (:affectedDimensionSpacePointHashes)',
[
'contentStreamId' => (string)$contentStreamId,
'contentStreamId' => $contentStreamId->value,
'descendantNodeAggregateIds' => array_keys($descendantNodeAggregateIds),
'affectedDimensionSpacePointHashes' => $affectedDimensionSpacePoints->getPointHashes()
],
Expand Down
Loading