function ContextDefinition::__construct

Same name in this branch
  1. 8.9.x core/lib/Drupal/Core/Annotation/ContextDefinition.php \Drupal\Core\Annotation\ContextDefinition::__construct()
Same name in other branches
  1. 9 core/lib/Drupal/Core/Annotation/ContextDefinition.php \Drupal\Core\Annotation\ContextDefinition::__construct()
  2. 9 core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php \Drupal\Core\Plugin\Context\ContextDefinition::__construct()
  3. 10 core/lib/Drupal/Core/Annotation/ContextDefinition.php \Drupal\Core\Annotation\ContextDefinition::__construct()
  4. 10 core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php \Drupal\Core\Plugin\Context\ContextDefinition::__construct()
  5. 11.x core/lib/Drupal/Core/Annotation/ContextDefinition.php \Drupal\Core\Annotation\ContextDefinition::__construct()
  6. 11.x core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php \Drupal\Core\Plugin\Context\ContextDefinition::__construct()

Constructs a new context definition object.

Parameters

string $data_type: The required data type.

string|null $label: The label of this context definition for the UI.

bool $required: Whether the context definition is required.

bool $multiple: Whether the context definition is multivalue.

string|null $description: The description of this context definition for the UI.

mixed $default_value: The default value of this definition.

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

File

core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php, line 136

Class

ContextDefinition
Defines a class for context definitions.

Namespace

Drupal\Core\Plugin\Context

Code

public function __construct($data_type = 'any', $label = NULL, $required = TRUE, $multiple = FALSE, $description = NULL, $default_value = NULL) {
    $this->dataType = $data_type;
    $this->label = $label;
    $this->isRequired = $required;
    $this->isMultiple = $multiple;
    $this->description = $description;
    $this->defaultValue = $default_value;
    if (strpos($data_type, 'entity:') === 0 && !$this instanceof EntityContextDefinition) {
        @trigger_error('Constructing a ContextDefinition object for an entity type is deprecated in Drupal 8.6.0. Use ' . __NAMESPACE__ . '\\EntityContextDefinition instead. See https://www.drupal.org/node/2976400 for more information.', E_USER_DEPRECATED);
        $this->initializeEntityContextDefinition();
    }
}

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