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

ImageStyleId   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A buildValues() 0 11 2
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