class Plugin

Defines a Plugin annotation object.

Annotations in plugin classes can utilize this class in order to pass various metadata about the plugin through the parser to DiscoveryInterface::getDefinitions() calls. This allows the metadata of a class to be located with the class itself, rather than in module-based info hooks.

Hierarchy

Expanded class hierarchy of Plugin

289 files declare their use of Plugin
Access.php in drupal/core/modules/node/lib/Drupal/node/Plugin/views/filter/Access.php
Definition of Drupal\node\Plugin\views\filter\Access.
AnnotatedClassDiscovery.php in drupal/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php
Definition of Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery.
Apple.php in drupal/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/fruit/Apple.php
Definition of Drupal\plugin_test\Plugin\plugin_test\fruit\Apple.
ArgumentDefaultTest.php in drupal/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/argument_default/ArgumentDefaultTest.php
Definition of Drupal\views_test_data\Plugin\views\argument_default\ArgumentDefaultTest.
Attachment.php in drupal/core/modules/views/lib/Drupal/views/Plugin/views/display/Attachment.php
Definition of Drupal\views\Plugin\views\display\Attachment.

... See full list

1 string reference to 'Plugin'
281 classes are annotated with Plugin
Access in drupal/core/modules/node/lib/Drupal/node/Plugin/views/filter/Access.php
Filter by node_access records.
Apple in drupal/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/fruit/Apple.php
Plugin annotation @Plugin( id = "apple", label = "Apple", color = "green" )
ArgumentDefaultTest in drupal/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/argument_default/ArgumentDefaultTest.php
Defines a argument default test plugin.
Attachment in drupal/core/modules/views/lib/Drupal/views/Plugin/views/display/Attachment.php
The plugin that handles an attachment display.
Banana in drupal/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/fruit/Banana.php
Plugin annotation @Plugin( id = "banana", label = "Banana", color = "yellow", uses = { "bread" = @Translation("Banana bread") } )

... See full list

File

drupal/core/lib/Drupal/Core/Annotation/Plugin.php, line 23
Definition of Drupal\Core\Annotation\Plugin.

Namespace

Drupal\Core\Annotation
View source
class Plugin implements AnnotationInterface {

  /**
   * The plugin definiton read from the class annotation.
   *
   * @var array
   */
  protected $definition;

  /**
   * Constructs a Plugin object.
   *
   * Builds up the plugin definition and invokes the get() method for any
   * classed annotations that were used.
   */
  public function __construct($values) {
    $this->definition = $this
      ->parse($values);
  }

  /**
   * Parses an annotation into its definition.
   *
   * @param array $values
   *   The annotation array.
   *
   * @return array
   *  The parsed annotation as a definition.
   */
  protected function parse(array $values) {
    $definitions = array();
    foreach ($values as $key => $value) {
      if ($value instanceof AnnotationInterface) {
        $definitions[$key] = $value
          ->get();
      }
      elseif (is_array($value)) {
        $definitions[$key] = $this
          ->parse($value);
      }
      else {
        $definitions[$key] = $value;
      }
    }
    return $definitions;
  }

  /**
   * Implements Drupal\Core\Annotation\AnnotationInterface::get().
   */
  public function get() {
    return $this->definition;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Plugin::$definition protected property The plugin definiton read from the class annotation.
Plugin::get public function Implements Drupal\Core\Annotation\AnnotationInterface::get(). Overrides AnnotationInterface::get
Plugin::parse protected function Parses an annotation into its definition.
Plugin::__construct public function Constructs a Plugin object.