Completed
Pull Request — 8.x-3.x (#525)
by Sebastian
02:06
created

SchemaPluginManager   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 41
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 20 20 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Drupal\graphql\Plugin;
4
5
use Drupal\Core\Cache\CacheBackendInterface;
6
use Drupal\Core\Extension\ModuleHandlerInterface;
7
use Drupal\Core\Plugin\DefaultPluginManager;
8
9 View Code Duplication
class SchemaPluginManager extends DefaultPluginManager {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
11
  /**
12
   * SchemaPluginManager constructor.
13
   *
14
   * @param bool|string $pluginSubdirectory
15
   *   The plugin's subdirectory.
16
   * @param \Traversable $namespaces
17
   *   An object that implements \Traversable which contains the root paths
18
   *   keyed by the corresponding namespace to look for plugin implementations.
19
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
20
   *   The module handler.
21
   * @param \Drupal\Core\Cache\CacheBackendInterface $cacheBackend
22
   *   The cache backend.
23
   * @param string|null $pluginInterface
24
   *   The interface each plugin should implement.
25
   * @param string $pluginAnnotationName
26
   *   The name of the annotation that contains the plugin definition.
27
   */
28
  public function __construct(
29
    $pluginSubdirectory,
30
    \Traversable $namespaces,
31
    ModuleHandlerInterface $moduleHandler,
32
    CacheBackendInterface $cacheBackend,
33
    $pluginInterface,
34
    $pluginAnnotationName
35
  ) {
36
    parent::__construct(
37
      $pluginSubdirectory,
38
      $namespaces,
39
      $moduleHandler,
40
      $pluginInterface,
41
      $pluginAnnotationName
42
    );
43
44
    $this->alterInfo('graphql_schema');
45
    $this->useCaches(TRUE);
46
    $this->setCacheBackend($cacheBackend, 'schemas', ['graphql', 'graphql:schemas']);
47
  }
48
49
}
50