Skip to content

Commit 8607daf

Browse files
committed
docs: fix inconsistent variable name and add circular reference check to 'setParent()' method
1 parent 82d279c commit 8607daf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

docs/LTREE-TYPE.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ class MyEntity implements \Stringable
122122
throw new \InvalidArgumentException("Parent MyEntity can't be self");
123123
}
124124

125+
if (in_array($this->getId()->toBase58(), $parent->getPath()->getBranch(), true)) {
126+
throw new \InvalidArgumentException("Parent MyEntity can't be a child of the current MyEntity");
127+
}
128+
125129
$this->parent = $parent;
126130

127131
// Use createLeaf() to create a new Ltree instance
@@ -156,7 +160,7 @@ final readonly class MyEntityListener
156160
{
157161
if ($eventArgs->hasChangedField('path')) {
158162
foreach($entity->getChildren() as $child) {
159-
$child->setParent($myEntity);
163+
$child->setParent($entity);
160164
}
161165
}
162166
}

0 commit comments

Comments
 (0)