From b9f0825dd8c7c1f21a9843fce6aa54ef4a719178 Mon Sep 17 00:00:00 2001 From: Dawid Parafinski Date: Fri, 25 Oct 2024 13:45:42 +0200 Subject: [PATCH] IBX-8534: Added relationList helper --- src/bundle/Core/Resources/config/helpers.yml | 4 ++ src/lib/Helper/RelationListHelper.php | 47 ++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/lib/Helper/RelationListHelper.php diff --git a/src/bundle/Core/Resources/config/helpers.yml b/src/bundle/Core/Resources/config/helpers.yml index 1ea501e559..9f7d8ce313 100644 --- a/src/bundle/Core/Resources/config/helpers.yml +++ b/src/bundle/Core/Resources/config/helpers.yml @@ -65,3 +65,7 @@ services: Ibexa\Bundle\Core\SiteAccess\Config\IOConfigResolver: arguments: $complexConfigProcessor: '@Ibexa\Bundle\Core\SiteAccess\Config\ComplexConfigProcessor' + + Ibexa\Core\Helper\RelationListHelper: + arguments: + $contentService: '@ibexa.api.service.content' diff --git a/src/lib/Helper/RelationListHelper.php b/src/lib/Helper/RelationListHelper.php new file mode 100644 index 0000000000..8bdb40045c --- /dev/null +++ b/src/lib/Helper/RelationListHelper.php @@ -0,0 +1,47 @@ +contentService, + $versionInfo + ) + ); + + $relations = []; + /** @var \Ibexa\Contracts\Core\Repository\Values\Content\RelationList\RelationListItemInterface $relationListItem */ + foreach ($relationListIterator as $relationListItem) { + if ($relationListItem->hasRelation()) { + /** @var \Ibexa\Core\Repository\Values\Content\Relation $relation */ + $relation = $relationListItem->getRelation(); + $relations[] = $relation; + } + } + + return $relations; + } +}