function Plugin::__construct

Same name in other branches
  1. 8.9.x core/lib/Drupal/Component/Annotation/Plugin.php \Drupal\Component\Annotation\Plugin::__construct()
  2. 10 core/lib/Drupal/Component/Annotation/Plugin.php \Drupal\Component\Annotation\Plugin::__construct()
  3. 10 core/lib/Drupal/Component/Plugin/Attribute/Plugin.php \Drupal\Component\Plugin\Attribute\Plugin::__construct()
  4. 11.x core/lib/Drupal/Component/Annotation/Plugin.php \Drupal\Component\Annotation\Plugin::__construct()
  5. 11.x core/lib/Drupal/Component/Plugin/Attribute/Plugin.php \Drupal\Component\Plugin\Attribute\Plugin::__construct()

Constructs a Plugin object.

Builds up the plugin definition and invokes the get() method for any classed annotations that were used.

2 calls to Plugin::__construct()
CKEditor5Plugin::__construct in core/modules/ckeditor5/src/Annotation/CKEditor5Plugin.php
Overridden for compatibility with the AnnotationBridgeDecorator, which ensures YAML-defined CKEditor 5 plugin definitions are also processed by annotations. Unfortunately it does not (yet) support nested annotations. Force YAML-defined plugin…
MigrateField::__construct in core/modules/migrate_drupal/src/Annotation/MigrateField.php
Constructs a Plugin object.
3 methods override Plugin::__construct()
CKEditor5Plugin::__construct in core/modules/ckeditor5/src/Annotation/CKEditor5Plugin.php
Overridden for compatibility with the AnnotationBridgeDecorator, which ensures YAML-defined CKEditor 5 plugin definitions are also processed by annotations. Unfortunately it does not (yet) support nested annotations. Force YAML-defined plugin…
ContextDefinition::__construct in core/lib/Drupal/Core/Annotation/ContextDefinition.php
Constructs a new context definition object.
MigrateField::__construct in core/modules/migrate_drupal/src/Annotation/MigrateField.php
Constructs a Plugin object.

File

core/lib/Drupal/Component/Annotation/Plugin.php, line 35

Class

Plugin
Defines a Plugin annotation object.

Namespace

Drupal\Component\Annotation

Code

public function __construct($values) {
    $reflection = new \ReflectionClass($this);
    // Only keep actual default values by ignoring NULL values.
    $defaults = array_filter($reflection->getDefaultProperties(), function ($value) {
        return $value !== NULL;
    });
    $parsed_values = $this->parse($values);
    $this->definition = NestedArray::mergeDeepArray([
        $defaults,
        $parsed_values,
    ], TRUE);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.