Completed
Push — 8.x-3.x ( 9e14ee...debf70 )
by Philipp
02:28
created

ImageStyleId::buildValues()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 1
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Drupal\graphql_core\Plugin\GraphQL\Enums\Images;
4
5
use Drupal\graphql\Plugin\GraphQL\Enums\EnumPluginBase;
6
use Drupal\graphql\Plugin\GraphQL\PluggableSchemaManagerInterface;
7
use Drupal\image\Entity\ImageStyle as ImageStyleConfig;
8
9
/**
10
 * @GraphQLEnum(
11
 *   id = "image_style_id",
12
 *   name = "ImageStyleId"
13
 * )
14
 */
15
class ImageStyleId extends EnumPluginBase {
16
17
  public function buildValues(PluggableSchemaManagerInterface $schemaManager) {
18
    $items = [];
19
    foreach (ImageStyleConfig::loadMultiple() as $imageStyle) {
20
      $items[$imageStyle->id()] = [
21
        'value' => $imageStyle->id(),
22
        'name' => $imageStyle->id(),
23
        'description' => $imageStyle->label()
24
      ];
25
    }
26
    return $items;
27
  }
28
29
}
30