You are here

public function EntityContextDefinition::__construct in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Plugin/Context/EntityContextDefinition.php \Drupal\Core\Plugin\Context\EntityContextDefinition::__construct()
  2. 9 core/lib/Drupal/Core/Plugin/Context/EntityContextDefinition.php \Drupal\Core\Plugin\Context\EntityContextDefinition::__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.

Overrides ContextDefinition::__construct

File

core/lib/Drupal/Core/Plugin/Context/EntityContextDefinition.php, line 20

Class

EntityContextDefinition
Defines a class to provide entity 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) {

  // Prefix the data type with 'entity:' so that this class can be constructed
  // like so: new EntityContextDefinition('node')
  if (strpos($data_type, 'entity:') !== 0) {
    $data_type = "entity:{$data_type}";
  }
  parent::__construct($data_type, $label, $required, $multiple, $description, $default_value);
}