Skip to content

Commit

Permalink
IBX-7149: Changed fetchIterationFromContentList function to get all c…
Browse files Browse the repository at this point in the history
…ontents by content type by iteration
  • Loading branch information
mateuszdebinski committed Nov 23, 2023
1 parent fea39fa commit 21bfd4d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
13 changes: 12 additions & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,18 @@ parameters:
message: "#^Property Ibexa\\\\Bundle\\\\Core\\\\Command\\\\ReindexCommand\\:\\:\\$phpPath \\(string\\) does not accept string\\|null\\.$#"
count: 2
path: src/bundle/Core/Command/ReindexCommand.php

-
message: "#^Call to an undefined method iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Content\\>\\&Traversable\\:\\:valid\\(\\)\\.$#"
count: 1
path: src/bundle/Core/Command/ReindexCommand.php
-
message: "#^Call to an undefined method iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Content\\>\\&Traversable\\:\\:current\\(\\)\\.$#"
count: 1
path: src/bundle/Core/Command/ReindexCommand.php
-
message: "#^Call to an undefined method iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Content\\>\\&Traversable\\:\\:next\\(\\)\\.$#"
count: 1
path: src/bundle/Core/Command/ReindexCommand.php
-
message: "#^Access to an undefined property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ValueObject\\:\\:\\$fields\\.$#"
count: 1
Expand Down
17 changes: 9 additions & 8 deletions src/bundle/Core/Command/ReindexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,16 +481,17 @@ public function getDeprecatedAliases(): array

private function fetchIterationFromContentList(ContentList $contentList, int $iterationCount): Generator
{
$i = 1;
$contentIds = [];
foreach ($contentList as $content) {
$contentIds[] = $content->id;
if ($iterationCount <= $i) {
break;
$contentListIterator = $contentList->getIterator();

while ($contentListIterator->valid()) {
$contentIds = [];
for ($i = 0; $i < $iterationCount; ++$i) {
$contentIds[] = $contentListIterator->current()->id;
$contentListIterator->next();
}
++$i;

yield $contentIds;
}
yield $contentIds;
}
}

Expand Down

0 comments on commit 21bfd4d

Please sign in to comment.