ContextDefinition
class ContextDefinition extends Plugin (View source)
Defines a context definition annotation object.
Some plugins require various data contexts in order to function. This class supports that need by allowing the contexts to be easily defined within an annotation and return a ContextDefinitionInterface implementing class.
Properties
| protected ContextDefinitionInterface | $definition | The ContextDefinitionInterface object. |
Methods
Constructs a new context definition object.
Returns the value of an annotation.
Determines the context definition class to use.
Details
__construct($values)
Constructs a new context definition object.
in
Plugin at line 54
protected array
parse(array $values)
Parses an annotation into its definition.
get()
Returns the value of an annotation.
in
Plugin at line 80
string
getProvider()
Gets the name of the provider of the annotated class.
in
Plugin at line 87
setProvider(string $provider)
Sets the name of the provider of the annotated class.
in
Plugin at line 94
string
getId()
Gets the unique ID for this annotated class.
string
getClass()
Gets the class of the annotated class.
setClass(string $class)
Sets the class of the annotated class.
protected string
getDefinitionClass(array $values)
Determines the context definition class to use.
If the annotation specifies a specific context definition class, we use that. Otherwise, we use \Drupal\Core\Plugin\Context\EntityContextDefinition if the data type starts with 'entity:', since it contains specialized logic specific to entities. Otherwise, we fall back to the generic \Drupal\Core\Plugin\Context\ContextDefinition class.