Skip to content

Commit

Permalink
Added the position filed to the hierarchy to keep the same order in t…
Browse files Browse the repository at this point in the history
…he report as in the analysis.
  • Loading branch information
ruslanbaidan committed Nov 18, 2024
1 parent 4b21262 commit 82b1423
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/Entity/InstanceSuperClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,27 +504,30 @@ public function removeAllOperationalInstanceRisks(): self
public function getHierarchyArray(): array
{
if ($this->isRoot()) {
return [array_merge($this->getNames(), ['id' => $this->id, 'root' => null, 'parent' => null])];
return [array_merge(
$this->getNames(),
['id' => $this->id, 'root' => null, 'parent' => null, 'position' => $this->position]
)];
}

return $this->getParents();
return $this->getParentsArray();
}

private function getParents(): array
private function getParentsArray(): array
{
if ($this->isRoot() || $this->getParent() === null) {
return [array_merge($this->getNames(), ['id' => $this->getId(), 'root' => null, 'parent' => null])];
return [array_merge(
$this->getNames(),
['id' => $this->getId(), 'root' => null, 'parent' => null, 'position' => $this->getPosition()]
)];
}

return array_merge(
$this->getParent()->getParents(),
[
array_merge(
$this->getNames(),
['id' => $this->getId(), 'root' => $this->getRoot(), 'parent' => $this->getParent()]
)
]
);
return array_merge($this->getParent()->getParentsArray(), [array_merge($this->getNames(), [
'id' => $this->getId(),
'root' => $this->getRoot(),
'parent' => $this->getParent(),
'position' => $this->getPosition(),
])]);
}

/**
Expand Down

0 comments on commit 82b1423

Please sign in to comment.