Completed
Push — 8.x-3.x ( 32ff4d...d01c55 )
by Sebastian
05:23 queued 02:25
created

EntityCrudOutputErrors::resolveValues()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 5
nc 4
nop 3
dl 0
loc 9
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
namespace Drupal\graphql_core\Plugin\GraphQL\Fields\Mutations;
4
5
use Drupal\graphql_core\GraphQL\EntityCrudOutputWrapper;
6
use Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase;
7
use Youshido\GraphQL\Execution\ResolveInfo;
8
9
/**
10
 * Retrieve a list of error messages.
11
 *
12
 * @GraphQLField(
13
 *   id = "entity_crud_output_errors",
14
 *   secure = true,
15
 *   name = "errors",
16
 *   type = "String",
17
 *   parents = {"EntityCrudOutput"},
18
 *   multi = true,
19
 *   nullable = false
20
 * )
21
 */
22
class EntityCrudOutputErrors extends FieldPluginBase {
23
24
  /**
25
   * {@inheritdoc}
26
   */
27
  public function resolveValues($value, array $args, ResolveInfo $info) {
28
    if ($value instanceof EntityCrudOutputWrapper) {
29
      if ($errors = $value->getErrors()) {
30
        foreach ($errors as $error) {
31
          yield $error;
32
        }
33
      }
34
    }
35
  }
36
37
}
38