Skip to content

Commit 34cb89d

Browse files
author
Bertrand Dunogier
committed
Added an ImageVariationIdentifier enum with the variations list (#38)
1 parent bba4d2d commit 34cb89d

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

Resources/config/domain_content.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,5 @@ services:
4848
BD\EzPlatformGraphQLBundle\DomainContent\FieldValueBuilder\SelectionFieldValueBuilder:
4949
tags:
5050
- {name: ezplatform_graphql.field_value_builder, type: 'ezselection'}
51+
52+
BD\EzPlatformGraphQLBundle\Schema\ImagesVariationsBuilder: ~

Schema/ImagesVariationsBuilder.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
namespace BD\EzPlatformGraphQLBundle\Schema;
3+
4+
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ConfigResolver;
5+
6+
/**
7+
* Generates the ImageVariationIdentifier enum that indexes images variations identifiers.
8+
*/
9+
class ImagesVariationsBuilder implements SchemaBuilder
10+
{
11+
/**
12+
* @var ConfigResolver
13+
*/
14+
private $configResolver;
15+
16+
public function __construct(ConfigResolver $configResolver)
17+
{
18+
$this->configResolver = $configResolver;
19+
}
20+
21+
public function build(array &$schema)
22+
{
23+
$schema['ImageVariationIdentifier'] = [
24+
'type' => 'enum',
25+
'config' => [
26+
'values' => []
27+
]
28+
];
29+
30+
$values =& $schema['ImageVariationIdentifier']['config']['values'];
31+
32+
foreach (array_keys($this->configResolver->getParameter('image_variations')) as $variationIdentifier) {
33+
$values[$variationIdentifier] = [];
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)