abstract class ExpressionBase in Rules 8.3
Base class for rules expressions.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\rules\Engine\ExpressionBase implements ExpressionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of ExpressionBase
3 files declare their use of ExpressionBase
- ActionExpression.php in src/
Plugin/ RulesExpression/ ActionExpression.php - ConditionExpression.php in src/
Plugin/ RulesExpression/ ConditionExpression.php - RuleExpression.php in src/
Plugin/ RulesExpression/ RuleExpression.php
File
- src/
Engine/ ExpressionBase.php, line 11
Namespace
Drupal\rules\EngineView source
abstract class ExpressionBase extends PluginBase implements ExpressionInterface {
/**
* The plugin configuration.
*
* @var array
*/
protected $configuration;
/**
* The root expression if this object is nested.
*
* @var \Drupal\rules\Engine\ExpressionInterface
*/
protected $root;
/**
* The config entity this expression is associated with, if any.
*
* @var string
*/
protected $configEntityId;
/**
* The UUID of this expression.
*
* @var string
*/
protected $uuid;
/**
* The weight (list order) of this expression.
*
* @var int
*/
protected $weight = 0;
/**
* Constructor.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this
->setConfiguration($configuration);
}
/**
* Executes a rules expression.
*/
public function execute() {
// If there is no state given, we have to assume no required context.
$state = ExecutionState::create();
$result = $this
->executeWithState($state);
// Save specifically registered variables in the end after execution.
$state
->autoSave();
return $result;
}
/**
* {@inheritdoc}
*/
public function getConfiguration() {
return [
'id' => $this
->getPluginId(),
'uuid' => $this->uuid,
'weight' => $this->weight,
] + $this->configuration;
}
/**
* {@inheritdoc}
*/
public function setConfiguration(array $configuration) {
$this->configuration = $configuration + $this
->defaultConfiguration();
if (isset($configuration['uuid'])) {
$this->uuid = $configuration['uuid'];
}
if (isset($configuration['weight'])) {
$this->weight = $configuration['weight'];
}
return $this;
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [];
}
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
return [];
}
/**
* {@inheritdoc}
*/
public function getFormHandler() {
if (isset($this->pluginDefinition['form_class'])) {
$class_name = $this->pluginDefinition['form_class'];
return new $class_name($this);
}
}
/**
* {@inheritdoc}
*/
public function getRoot() {
if (isset($this->root)) {
// @todo This seems to be the parent, not root.
return $this->root
->getRoot();
}
return $this;
}
/**
* {@inheritdoc}
*/
public function setRoot(ExpressionInterface $root) {
$this->root = $root;
return $this;
}
/**
* {@inheritdoc}
*/
public function getLabel() {
return $this->pluginDefinition['label'];
}
/**
* {@inheritdoc}
*/
public function getUuid() {
return $this->uuid;
}
/**
* {@inheritdoc}
*/
public function setUuid($uuid) {
$this->uuid = $uuid;
return $this;
}
/**
* {@inheritdoc}
*/
public function getWeight() {
return $this->weight;
}
/**
* {@inheritdoc}
*/
public function setWeight($weight) {
$this->weight = $weight;
return $this;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
ExpressionBase:: |
protected | property | The config entity this expression is associated with, if any. | |
ExpressionBase:: |
protected | property |
The plugin configuration. Overrides PluginBase:: |
|
ExpressionBase:: |
protected | property | The root expression if this object is nested. | |
ExpressionBase:: |
protected | property | The UUID of this expression. | |
ExpressionBase:: |
protected | property | The weight (list order) of this expression. | |
ExpressionBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
ExpressionBase:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurableInterface:: |
2 |
ExpressionBase:: |
public | function |
Executes a rules expression. Overrides ExecutableInterface:: |
|
ExpressionBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
3 |
ExpressionBase:: |
public | function |
Returns the form handling class for this expression. Overrides ExpressionInterface:: |
2 |
ExpressionBase:: |
public | function |
The label of this expression element that can be shown in the UI. Overrides ExpressionInterface:: |
2 |
ExpressionBase:: |
public | function |
Returns the root expression if this expression is nested. Overrides ExpressionInterface:: |
|
ExpressionBase:: |
public | function |
Returns the UUID of this expression if it is nested in another expression. Overrides ExpressionInterface:: |
|
ExpressionBase:: |
public | function |
Returns the list order of this expression. Overrides ExpressionInterface:: |
|
ExpressionBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
2 |
ExpressionBase:: |
public | function |
Set the root expression for this expression if it is nested. Overrides ExpressionInterface:: |
|
ExpressionBase:: |
public | function |
Sets the UUID of this expression in an expression tree. Overrides ExpressionInterface:: |
|
ExpressionBase:: |
public | function |
Sets the list order of this expression in an expression tree. Overrides ExpressionInterface:: |
|
ExpressionBase:: |
public | function |
Constructor. Overrides PluginBase:: |
5 |
ExpressionInterface:: |
public | function | Verifies that this expression is configured correctly. | 4 |
ExpressionInterface:: |
public | function | Execute the expression with a given Rules state. | 6 |
ExpressionInterface:: |
public | function | Prepares the execution metadata state by adding metadata to it. | 4 |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |