EntityCrudOutputViolations   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 5
c 0
b 0
f 0
dl 0
loc 10
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveValues() 0 5 4
1
<?php
2
3
namespace Drupal\graphql_core\Plugin\GraphQL\Fields\Mutations;
4
5
use Drupal\graphql\GraphQL\Execution\ResolveContext;
6
use Drupal\graphql_core\GraphQL\EntityCrudOutputWrapper;
7
use Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase;
8
use GraphQL\Type\Definition\ResolveInfo;
9
10
/**
11
 * Retrieve a list of entity mutation constraint violations.
12
 *
13
 * @GraphQLField(
14
 *   id = "entity_crud_output_violations",
15
 *   secure = true,
16
 *   name = "violations",
17
 *   type = "[ConstraintViolation]",
18
 *   parents = {"EntityCrudOutput"}
19
 * )
20
 */
21
class EntityCrudOutputViolations extends FieldPluginBase {
22
23
  /**
24
   * {@inheritdoc}
25
   */
26
  public function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
27
    if ($value instanceof EntityCrudOutputWrapper) {
28
      if ($violations = $value->getViolations()) {
29
        foreach ($violations as $violation) {
30
          yield $violation;
31
        }
32
      }
33
    }
34
  }
35
36
}
37