You are here

public function Plugin::__construct in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Component/Annotation/Plugin.php \Drupal\Component\Annotation\Plugin::__construct()

Constructs a Plugin object.

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

1 method overrides Plugin::__construct()
ContextDefinition::__construct in core/lib/Drupal/Core/Annotation/ContextDefinition.php
Constructs a new context definition object.

File

core/lib/Drupal/Component/Annotation/Plugin.php, line 40
Contains \Drupal\Component\Annotation\Plugin.

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::mergeDeep($defaults, $parsed_values);
}