ContextAwarePluginBase
abstract class ContextAwarePluginBase extends PluginBase implements ContextAwarePluginInterface (View source)
Base class for plugins that are context aware.
Constants
| DERIVATIVE_SEPARATOR |
A string which is used to separate base plugin IDs from the derivative ID. |
Properties
| protected string | $pluginId | The plugin_id. |
from PluginBase |
| protected array | $pluginDefinition | The plugin implementation definition. |
from PluginBase |
| protected array | $configuration | Configuration information passed into the plugin. |
from PluginBase |
| protected ContextInterface[] | $context | The data objects representing the context of this plugin. |
Methods
Overrides \Drupal\Component\Plugin\PluginBase::__construct().
Creates context objects from any context mappings in configuration.
Gets the context definitions of the plugin.
Gets a specific context definition of the plugin.
Gets the defined contexts.
Gets a defined context.
Gets the values for all defined contexts.
Gets the value for a defined context.
Sets the value for a defined context.
Validates the set values for the defined contexts.
Details
__construct(array $configuration, string $plugin_id, mixed $plugin_definition)
Overrides \Drupal\Component\Plugin\PluginBase::__construct().
Overrides the construction of context aware plugins to allow for unvalidated constructor based injection of contexts.
string
getPluginId()
Gets the plugin_id of the plugin instance.
string
getBaseId()
Gets the base_plugin_id of the plugin instance.
string|null
getDerivativeId()
Gets the derivative_id of the plugin instance.
array
getPluginDefinition()
Gets the definition of the plugin implementation.
bool
isConfigurable()
Determines if the plugin is configurable.
protected ContextInterface[]
createContextFromConfiguration(array $context_configuration)
Creates context objects from any context mappings in configuration.
ContextDefinitionInterface[]
getContextDefinitions()
Gets the context definitions of the plugin.
ContextDefinitionInterface
getContextDefinition(string $name)
Gets a specific context definition of the plugin.
array
getContexts()
Gets the defined contexts.
ContextInterface
getContext(string $name)
Gets a defined context.
setContext(string $name, ContextInterface $context)
Set a context on this plugin.
array
getContextValues()
Gets the values for all defined contexts.
mixed
getContextValue(string $name)
Gets the value for a defined context.
$this
setContextValue(string $name, mixed $value)
Sets the value for a defined context.
ConstraintViolationListInterface
validateContexts()
Validates the set values for the defined contexts.