Skip to content

Commit 540f4fe

Browse files
committed
ViewContentMetaDataCommand.php: Use RelationListIteratorAdapter
1 parent aba03c3 commit 540f4fe

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace App\Command;
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\Contracts\Core\Repository\ObjectStateService;
810
use Ibexa\Contracts\Core\Repository\PermissionResolver;
@@ -99,9 +101,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
99101

100102
// Relations
101103
$versionInfo = $this->contentService->loadVersionInfo($contentInfo);
102-
$relationCount = $this->contentService->countRelations($versionInfo);
103-
$relationList = $this->contentService->loadRelationList($versionInfo, 0, $relationCount);
104-
foreach ($relationList as $relationListItem) {
104+
$relationListIterator = new BatchIterator(
105+
new RelationListIteratorAdapter(
106+
$this->contentService,
107+
$versionInfo
108+
)
109+
);
110+
foreach ($relationListIterator as $relationListItem) {
105111
$name = $relationListItem->hasRelation() ? $relationListItem->getRelation()->destinationContentInfo->name : '(Unauthorized)';
106112
$output->writeln("Relation to content '$name'");
107113
}

0 commit comments

Comments
 (0)