public function ContextDefinition::__construct in Rules 8.3
Same name in this branch
- 8.3 src/Context/ContextDefinition.php \Drupal\rules\Context\ContextDefinition::__construct()
 - 8.3 src/Context/Annotation/ContextDefinition.php \Drupal\rules\Context\Annotation\ContextDefinition::__construct()
 
Constructs a new context definition object.
Parameters
array $values: An associative array with the following keys:
- value: The required data type.
 - label: (optional) The UI label of this context definition.
 - required: (optional) Whether the context definition is required.
 - multiple: (optional) Whether the context definition is multivalue.
 - description: (optional) The UI description of this context definition.
 - default_value: (optional) The default value in case the underlying value is not set.
 - class: (optional) A custom ContextDefinitionInterface class.
 
Throws
\Exception Thrown when the class key is specified with a non ContextDefinitionInterface implementing class.
Overrides ContextDefinition::__construct
File
- src/
Context/ Annotation/ ContextDefinition.php, line 31  
Class
- ContextDefinition
 - Extends the core context definition annotation object for Rules.
 
Namespace
Drupal\rules\Context\AnnotationCode
public function __construct(array $values) {
  // Filter out any @Translation annotation objects.
  foreach ($values as $key => $value) {
    if ($value instanceof Translation) {
      $values[$key] = $value
        ->get();
    }
  }
  $this->definition = RulesContextDefinition::createFromArray($values);
}