Skip to content

Commit b700b7f

Browse files
committed
allow 0 to remove parent
1 parent 208fde8 commit b700b7f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Service/Taxonomy.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ public function update(string $taxonomyId, TaxonomyUpdate $taxonomy, UserContext
9898
$this->taxonomyTable->beginTransaction();
9999

100100
// update taxonomy
101-
$existing->setParentId($taxonomy->getParentId() ?? $existing->getParentId());
101+
$parentId = $taxonomy->getParentId() ?? $existing->getParentId();
102+
if ($parentId === 0) {
103+
$parentId = null;
104+
}
105+
106+
$existing->setParentId($parentId);
102107
$existing->setName($taxonomy->getName() ?? $existing->getName());
103108
$this->taxonomyTable->update($existing);
104109

src/Service/Taxonomy/Validator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function assert(Taxonomy $taxonomy, ?string $tenantId, ?Table\Generated\T
4646
$this->usageLimiter->assertTaxonomyCount($tenantId);
4747

4848
$parentId = $taxonomy->getParentId();
49-
if ($parentId !== null) {
49+
if ($parentId !== null && $parentId !== 0) {
5050
$this->assertParentId($parentId, $tenantId, $existing);
5151
}
5252

0 commit comments

Comments
 (0)