From d2966901eb6999b315c4432b47cee12332bce8b3 Mon Sep 17 00:00:00 2001 From: Ambroise Maupate Date: Fri, 7 Jun 2024 12:11:01 +0200 Subject: [PATCH] chore: Fixed nullable Tag Dto `parentId` --- lib/RoadizCoreBundle/src/Model/TagTreeDto.php | 4 ++-- lib/Rozier/src/Widgets/NodeTreeWidget.php | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/RoadizCoreBundle/src/Model/TagTreeDto.php b/lib/RoadizCoreBundle/src/Model/TagTreeDto.php index 2020dd43..3f097d67 100644 --- a/lib/RoadizCoreBundle/src/Model/TagTreeDto.php +++ b/lib/RoadizCoreBundle/src/Model/TagTreeDto.php @@ -17,7 +17,7 @@ public function __construct( private readonly ?string $name, private readonly string $color, private readonly bool $visible, - private readonly int $parentId, + private readonly ?int $parentId, ) { } @@ -46,7 +46,7 @@ public function isVisible(): bool return $this->visible; } - public function getParentId(): int + public function getParentId(): ?int { return $this->parentId; } diff --git a/lib/Rozier/src/Widgets/NodeTreeWidget.php b/lib/Rozier/src/Widgets/NodeTreeWidget.php index 4e548da8..7e27595e 100644 --- a/lib/Rozier/src/Widgets/NodeTreeWidget.php +++ b/lib/Rozier/src/Widgets/NodeTreeWidget.php @@ -290,8 +290,11 @@ public function getNodes(): iterable /** * @return array */ - public function getTags(Node|NodeTreeDto $node): array + public function getTags(Node|NodeTreeDto|null $node): array { + if (null === $node) { + return []; + } return $this->managerRegistry->getRepository(Tag::class)->findByAsTagTreeDto([ "nodes" => $node->getId(), ], [