PluginBase   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 37
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
1
<?php
2
3
namespace Drupal\paragraphs_editor\Plugin\ParagraphsEditor;
4
5
use Drupal\paragraphs_editor\EditorCommand\CommandContextInterface;
6
7
/**
8
 * Provides a basic plugin base for creating paragraphs_editor plugins.
9
 *
10
 * This base class gives you a simple starting point for writing plugins that
11
 * deal with editor command contexts. If you extend from this base you can
12
 * simply access the context as a protected member variable.
13
 *
14
 * @code
15
 * $this->context->getContextString()
16
 * @endcode
17
 */
18
abstract class PluginBase {
19
20
  /**
21
   * The plugin id for this plugin.
22
   *
23
   * @var string
24
   */
25
  protected $pluginId;
26
27
  /**
28
   * The plugin definition for this plugin.
29
   *
30
   * @var object
31
   */
32
  protected $pluginDefinition;
33
34
  /**
35
   * The command context the plugin is executing within.
36
   *
37
   * @var \Drupal\paragraphs_editor\EditorCommand\CommandContextInterface
38
   */
39
  protected $context;
40
41
  /**
42
   * Creates a plugin object.
43
   *
44
   * @param string $plugin_id
45
   *   The drupal plugin id as defined in the annotation.
46
   * @param object $plugin_definition
47
   *   The plugin definition object.
48
   * @param \Drupal\paragraphs_editor\EditorCommand\CommandContextInterface $context
49
   *   The command context which the plugin will be executed within.
50
   */
51
  public function __construct($plugin_id, $plugin_definition, CommandContextInterface $context) {
52
    $this->pluginId = $plugin_id;
53
    $this->pluginDefinition = $plugin_definition;
54
    $this->context = $context;
55
  }
56
57
}
58