diff --git a/src/Tag/Service/TagService.php b/src/Tag/Service/TagService.php index 1c4165d5..69baab3b 100644 --- a/src/Tag/Service/TagService.php +++ b/src/Tag/Service/TagService.php @@ -70,18 +70,21 @@ public function getTag(int $id): Tag */ public function getTagsForElement(ElementParameters $tagElement): array { - $result = []; + $this->checkElementPermission( $tagElement->getType(), $tagElement->getId(), ElementPermissions::VIEW_PERMISSION ); + + $results = []; foreach ($this->tagRepository->getTagsForElement($tagElement) as $tag) { - $result[$tag->getId()] = $this->tagHydrator->hydrate($tag); - $this->dispatchTagEvent($result[$tag->getId()]); + $result = $this->tagHydrator->hydrate($tag); + $this->dispatchTagEvent($result); + $results[] = $result; } - return $result; + return $results; } /**