Code Duplication    Length = 59-59 lines in 2 locations

src/Plugin/FieldPluginManager.php 1 location

@@ 9-67 (lines=59) @@
6
use Drupal\Core\Extension\ModuleHandlerInterface;
7
use Drupal\Core\Plugin\DefaultPluginManager;
8
9
class FieldPluginManager extends DefaultPluginManager {
10
11
  /**
12
   * Static cache of plugin instances.
13
   *
14
   * @var \Drupal\graphql\Plugin\FieldPluginInterface[]
15
   */
16
  protected $instances;
17
18
  /**
19
   * FieldPluginManager constructor.
20
   *
21
   * @param bool|string $pluginSubdirectory
22
   *   The plugin's subdirectory.
23
   * @param \Traversable $namespaces
24
   *   An object that implements \Traversable which contains the root paths
25
   *   keyed by the corresponding namespace to look for plugin implementations.
26
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
27
   *   The module handler.
28
   * @param \Drupal\Core\Cache\CacheBackendInterface $cacheBackend
29
   *   The cache backend.
30
   * @param string|null $pluginInterface
31
   *   The interface each plugin should implement.
32
   * @param string $pluginAnnotationName
33
   *   The name of the annotation that contains the plugin definition.
34
   */
35
  public function __construct(
36
    $pluginSubdirectory,
37
    \Traversable $namespaces,
38
    ModuleHandlerInterface $moduleHandler,
39
    CacheBackendInterface $cacheBackend,
40
    $pluginInterface,
41
    $pluginAnnotationName
42
  ) {
43
    parent::__construct(
44
      $pluginSubdirectory,
45
      $namespaces,
46
      $moduleHandler,
47
      $pluginInterface,
48
      $pluginAnnotationName
49
    );
50
51
    $this->alterInfo('graphql_fields');
52
    $this->useCaches(TRUE);
53
    $this->setCacheBackend($cacheBackend, 'fields', ['graphql', 'graphql:fields']);
54
  }
55
56
  /**
57
   * {@inheritdoc}
58
   */
59
  public function getInstance(array $options) {
60
    if (!isset($this->instances[$options['id']])) {
61
      $this->instances[$options['id']] = $this->createInstance($options['id']);
62
    }
63
64
    return $this->instances[$options['id']];
65
  }
66
67
}
68

src/Plugin/MutationPluginManager.php 1 location

@@ 9-67 (lines=59) @@
6
use Drupal\Core\Extension\ModuleHandlerInterface;
7
use Drupal\Core\Plugin\DefaultPluginManager;
8
9
class MutationPluginManager extends DefaultPluginManager {
10
11
  /**
12
   * Static cache of plugin instances.
13
   *
14
   * @var \Drupal\graphql\Plugin\MutationPluginInterface[]
15
   */
16
  protected $instances;
17
18
  /**
19
   * FieldPluginManager constructor.
20
   *
21
   * @param bool|string $pluginSubdirectory
22
   *   The plugin's subdirectory.
23
   * @param \Traversable $namespaces
24
   *   An object that implements \Traversable which contains the root paths
25
   *   keyed by the corresponding namespace to look for plugin implementations.
26
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
27
   *   The module handler.
28
   * @param \Drupal\Core\Cache\CacheBackendInterface $cacheBackend
29
   *   The cache backend.
30
   * @param string|null $pluginInterface
31
   *   The interface each plugin should implement.
32
   * @param string $pluginAnnotationName
33
   *   The name of the annotation that contains the plugin definition.
34
   */
35
  public function __construct(
36
    $pluginSubdirectory,
37
    \Traversable $namespaces,
38
    ModuleHandlerInterface $moduleHandler,
39
    CacheBackendInterface $cacheBackend,
40
    $pluginInterface,
41
    $pluginAnnotationName
42
  ) {
43
    parent::__construct(
44
      $pluginSubdirectory,
45
      $namespaces,
46
      $moduleHandler,
47
      $pluginInterface,
48
      $pluginAnnotationName
49
    );
50
51
    $this->alterInfo('graphql_mutations');
52
    $this->useCaches(TRUE);
53
    $this->setCacheBackend($cacheBackend, 'mutations', ['graphql', 'graphql:mutations']);
54
  }
55
56
  /**
57
   * {@inheritdoc}
58
   */
59
  public function getInstance(array $options) {
60
    if (!isset($this->instances[$options['id']])) {
61
      $this->instances[$options['id']] = $this->createInstance($options['id']);
62
    }
63
64
    return $this->instances[$options['id']];
65
  }
66
67
}
68