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

EntityCrudOutputEntity   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveValues() 0 7 4
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 the mutated entity.
11
 *
12
 * @GraphQLField(
13
 *   id = "entity_crud_output_entity",
14
 *   secure = true,
15
 *   name = "entity",
16
 *   type = "Entity",
17
 *   parents = {"EntityCrudOutput"},
18
 *   nullable = true
19
 * )
20
 */
21
class EntityCrudOutputEntity extends FieldPluginBase {
22
23
  /**
24
   * {@inheritdoc}
25
   */
26
  public function resolveValues($value, array $args, ResolveInfo $info) {
27
    if ($value instanceof EntityCrudOutputWrapper) {
28
      if (($entity = $value->getEntity()) && $entity->access('view')) {
29
        yield $entity;
30
      }
31
    }
32
  }
33
34
}
35