Completed
Pull Request — 8.x-1.x (#22)
by
unknown
01:26
created

ViewDerivative   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveValues() 0 9 1
1
<?php
2
3
namespace Drupal\graphql_views\Plugin\GraphQL\Fields\Entity\Fields\View;
4
5
use Drupal\graphql\GraphQL\Execution\ResolveContext;
6
use Drupal\graphql_views\Plugin\GraphQL\Fields\View;
7
use GraphQL\Type\Definition\ResolveInfo;
8
9
/**
10
 * Retrieve the image field derivative (image style).
11
 *
12
 * @GraphQLField(
13
 *   id = "view_derivative",
14
 *   secure = true,
15
 *   name = "viewDerivative",
16
 *   type = "View",
17
 *   field_types = {"viewsreference"},
18
 *   provider = "views",
19
 *   deriver = "Drupal\graphql_core\Plugin\Deriver\Fields\EntityFieldPropertyDeriver"
20
 * )
21
 */
22
class ViewDerivative extends View {
23
24
  /**
25
   * {@inheritdoc}
26
   */
27
  public function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
28
    $values = $value->getValue();
29
    $this->pluginDefinition['view'] = $values['target_id'];
30
    $this->pluginDefinition['display'] = $values['display_id'];
31
    // TODO: add support for arguments and paged?
32
    // $this->pluginDefinition['arguments_info']
33
    // $this->pluginDefinition['paged']
34
    return parent::resolveValues($value, $args, $context, $info);
35
  }
36
37
}
38