Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.0: Use RelationListIterator #2548

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace App\Command;

use Ibexa\Contracts\Core\Repository\ContentService;
use Ibexa\Contracts\Core\Repository\Iterator\BatchIterator;
use Ibexa\Contracts\Core\Repository\Iterator\BatchIteratorAdapter\RelationListIteratorAdapter;
use Ibexa\Contracts\Core\Repository\LocationService;
use Ibexa\Contracts\Core\Repository\ObjectStateService;
use Ibexa\Contracts\Core\Repository\PermissionResolver;
Expand Down Expand Up @@ -99,9 +101,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int

// Relations
$versionInfo = $this->contentService->loadVersionInfo($contentInfo);
$relationCount = $this->contentService->countRelations($versionInfo);
$relationList = $this->contentService->loadRelationList($versionInfo, 0, $relationCount);
foreach ($relationList as $relationListItem) {
$relationListIterator = new BatchIterator(
new RelationListIteratorAdapter(
$this->contentService,
$versionInfo
)
);
foreach ($relationListIterator as $relationListItem) {
$name = $relationListItem->hasRelation() ? $relationListItem->getRelation()->destinationContentInfo->name : '(Unauthorized)';
$output->writeln("Relation to content '$name'");
}
Expand Down
Loading
Loading