Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Generator;
use Ibexa\Bundle\Core\Command\Indexer\ContentIdListGeneratorStrategyInterface;
use Ibexa\Contracts\Core\Repository\ContentService;
use Ibexa\Contracts\Core\Repository\Repository;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentList;
use Ibexa\Contracts\Core\Repository\Values\Content\Query;
use Ibexa\Contracts\Core\Repository\Values\Filter\Filter;
Expand All @@ -24,9 +25,12 @@
{
private ContentService $contentService;

public function __construct(ContentService $contentService)
private Repository $repository;

public function __construct(ContentService $contentService, Repository $repository)
{
$this->contentService = $contentService;
$this->repository = $repository;
}

/**
Expand Down Expand Up @@ -74,6 +78,11 @@
)
;

return $this->contentService->find($filter);
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentList $contentList */
$contentList = $this->repository->sudo(function () use ($filter) {

Check warning on line 82 in src/bundle/Core/Command/Indexer/ContentIdList/ContentTypeInputGeneratorStrategy.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Immediately return this expression instead of assigning it to the temporary variable "$contentList".

See more on https://sonarcloud.io/project/issues?id=ibexa_core&issues=AZ6Xoz1-f6rVfIBwb6Kf&open=AZ6Xoz1-f6rVfIBwb6Kf&pullRequest=760
return $this->contentService->find($filter);
});

return $contentList;
}
}
2 changes: 1 addition & 1 deletion src/bundle/Core/Command/ReindexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function __construct(
bool $isDebug,
string $projectDir,
ContentIdListGeneratorStrategyInterface $contentIdListGeneratorStrategy,
?string $phpPath = null
?string $phpPath = null,
) {
$this->gateway = $gateway;
$this->searchIndexer = $searchIndexer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use Ibexa\Bundle\Core\Command\Indexer\ContentIdList\ContentTypeInputGeneratorStrategy;
use Ibexa\Contracts\Core\Repository\ContentService;
use Ibexa\Contracts\Core\Repository\Repository;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentList;
use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo;
Expand All @@ -32,10 +33,20 @@ public function testGetGenerator(ContentList $contentList, int $batchSize, array
$contentServiceMock = $this->createMock(ContentService::class);
$contentServiceMock->method('find')->willReturn($contentList);

$repositoryMock = $this->createMock(Repository::class);
$repositoryMock
->method('sudo')
->willReturnCallback(
static fn (callable $callback) => $callback()
);

$inputMock = $this->createMock(InputInterface::class);
$inputMock->method('getOption')->with('content-type')->willReturn(uniqid('type', true));

$strategy = new ContentTypeInputGeneratorStrategy($contentServiceMock);
$strategy = new ContentTypeInputGeneratorStrategy(
$contentServiceMock,
$repositoryMock
);

self::assertSame(
$expectedBatches,
Expand Down
Loading