Completed
Pull Request — 8.x-3.x (#509)
by Sebastian
05:24 queued 02:06
created

LanguageSwitchLinkUrl   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveValues() 0 12 1
1
<?php
2
3
namespace Drupal\graphql_core\Plugin\GraphQL\Fields\LanguageSwitch;
4
5
use Drupal\Core\Url;
6
use Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase;
7
use Youshido\GraphQL\Execution\ResolveInfo;
8
9
/**
10
 * @GraphQLField(
11
 *   id = "language_switch_link_url",
12
 *   secure = true,
13
 *   name = "url",
14
 *   type = "InternalUrl",
15
 *   parents = {"LanguageSwitchLink"}
16
 * )
17
 */
18
class LanguageSwitchLinkUrl extends FieldPluginBase {
0 ignored issues
show
Bug introduced by
There is one abstract method getPluginDefinition in this class; you could implement it, or declare this class as abstract.
Loading history...
19
20
  /**
21
   * {@inheritdoc}
22
   */
23
  protected function resolveValues($value, array $args, ResolveInfo $info) {
24
    /** @var \Drupal\Core\Language\LanguageInterface $language */
25
    $language = $value['link']['language'];
26
27
    /** @var \Drupal\Core\Url $url */
28
    $url = $value['link']['url'];
29
    $url = Url::fromRoute($url->getRouteName(), $url->getRouteParameters(), [
30
      'language' => $language,
31
    ] + $url->getOptions());
32
33
    yield $url;
34
  }
35
36
}
37