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
12 changes: 11 additions & 1 deletion src/lib/UI/Config/Provider/Module/DamWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
*/
final class DamWidget implements ProviderInterface
{
private const IMAGE_TYPE_ID = 5;

/** @phpstan-var TConfig */
private array $config;

Expand Down Expand Up @@ -100,10 +102,18 @@ private function getImageConfig(): array
{
$imageConfig = [
'showImageFilters' => $this->showImageFilters(),
'aggregations' => $this->config['image']['aggregations'],
'aggregations' => [],
'enableMultipleDownload' => extension_loaded('zip'),
];

// The content type may not have the default fields; in that case, don't add the aggregations
$imageType = $this->contentTypeService->loadContentType(self::IMAGE_TYPE_ID);
foreach ($this->config['image']['aggregations'] as $key => $aggregation) {
if ($imageType->hasFieldDefinition($aggregation['fieldDefinitionIdentifier'])) {
$imageConfig['aggregations'][$key] = $aggregation;
}
}

$mappings = [];
$contentTypeIdentifiers = [];
$fieldDefinitionIdentifiers = [];
Expand Down
11 changes: 11 additions & 0 deletions tests/lib/UI/Config/Provider/Module/DamWidgetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public function testGetConfig(
$this->mockRepositoryConfigurationProviderGetRepositoryConfig($repositoryConfig);
$this->mockContentTypeServiceLoadContentTypeByIdentifier($loadContentTypeValueMap);
$this->mockSchemaIdentifierExtractorExtract($extractSchemaIdentifiersValueMap);
$this->mockContentTypeServiceLoadContentType();

self::assertEquals(
$expectedConfiguration,
Expand Down Expand Up @@ -263,6 +264,16 @@ private function mockContentTypeServiceLoadContentTypeByIdentifier(array $valueM
->willReturnMap($valueMap);
}

private function mockContentTypeServiceLoadContentType(): void
{
$contetnType = $this->createMock(ContentType::class);
$contetnType->method('hasFieldDefinition')->willReturn(true);

$this->contentTypeService
->method('loadContentType')
->willReturn($contetnType);
}

/**
* @param array<array{string|array<string>}> $valueMap
*/
Expand Down
Loading