Skip to content

Commit d4b3637

Browse files
committed
RelationController: use RelationListIteratorAdapter
1 parent 82f3b6e commit d4b3637

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

code_samples/front/embed_content/src/Controller/RelationController.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace App\Controller;
44

55
use Ibexa\Contracts\Core\Repository\ContentService;
6+
use Ibexa\Contracts\Core\Repository\Iterator\BatchIterator;
7+
use Ibexa\Contracts\Core\Repository\Iterator\BatchIteratorAdapter\RelationListIteratorAdapter;
68
use Ibexa\Contracts\Core\Repository\LocationService;
79
use Ibexa\Core\MVC\Symfony\View\View;
810

@@ -25,11 +27,16 @@ public function showContentAction(View $view, $locationId): View
2527
$location = $this->locationService->loadLocation($locationId);
2628
$contentInfo = $location->getContentInfo();
2729
$versionInfo = $this->contentService->loadVersionInfo($contentInfo);
28-
$relationList = $this->contentService->loadRelationList($versionInfo);
30+
$relationListIterator = new BatchIterator(
31+
new RelationListIteratorAdapter(
32+
$this->contentService,
33+
$versionInfo
34+
)
35+
);
2936

3037
$items = [];
3138

32-
foreach ($relationList as $relationListItem) {
39+
foreach ($relationListIterator as $relationListItem) {
3340
if ($relationListItem->hasRelation() && in_array($relationListItem->getRelation()->getDestinationContentInfo()->getContentType()->identifier, $acceptedContentTypes)) {
3441
$items[] = $this->contentService->loadContentByContentInfo($relationListItem->getRelation()->getDestinationContentInfo());
3542
}

0 commit comments

Comments
 (0)