abstract class ExpressionContainerBase in Rules 8.3
Common base class for action and condition expression containers.
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\rules\Engine\ExpressionContainerBase implements ExpressionContainerInterface
- class \Drupal\rules\Engine\ExpressionBase implements ExpressionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of ExpressionContainerBase
File
- src/
Engine/ ExpressionContainerBase.php, line 12
Namespace
Drupal\rules\EngineView source
abstract class ExpressionContainerBase extends ExpressionBase implements ExpressionContainerInterface {
/**
* The expression manager.
*
* @var \Drupal\rules\Engine\ExpressionManagerInterface
*/
protected $expressionManager;
/**
* The rules debug logger channel.
*
* @var \Drupal\Core\Logger\LoggerChannelInterface
*/
protected $rulesDebugLogger;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('plugin.manager.rules_expression'), $container
->get('logger.channel.rules_debug'));
}
/**
* Sorts an array of expressions by 'weight' property.
*
* Callback for uasort().
*
* @param \Drupal\rules\Engine\ExpressionInterface $a
* First item for comparison.
* @param \Drupal\rules\Engine\ExpressionInterface $b
* Second item for comparison.
*
* @return int
* The comparison result for uasort().
*/
public static function sortByWeightProperty(ExpressionInterface $a, ExpressionInterface $b) {
$a_weight = $a
->getWeight();
$b_weight = $b
->getWeight();
if ($a_weight == $b_weight) {
return 0;
}
return $a_weight < $b_weight ? -1 : 1;
}
/**
* {@inheritdoc}
*/
public function addExpression($plugin_id, ContextConfig $config = NULL) {
return $this
->addExpressionObject($this->expressionManager
->createInstance($plugin_id, $config ? $config
->toArray() : []));
}
/**
* Determines whether child-expressions are allowed to assert metadata.
*
* @return bool
* Whether child-expressions are allowed to assert metadata.
*
* @see \Drupal\rules\Engine\ExpressionInterface::prepareExecutionMetadataState()
*/
protected abstract function allowsMetadataAssertions();
/**
* {@inheritdoc}
*/
public function checkIntegrity(ExecutionMetadataStateInterface $metadata_state, $apply_assertions = TRUE) {
$violation_list = new IntegrityViolationList();
$this
->prepareExecutionMetadataStateBeforeTraversal($metadata_state);
$apply_assertions = $apply_assertions && $this
->allowsMetadataAssertions();
foreach ($this as $child_expression) {
$child_violations = $child_expression
->checkIntegrity($metadata_state, $apply_assertions);
$violation_list
->addAll($child_violations);
}
$this
->prepareExecutionMetadataStateAfterTraversal($metadata_state);
return $violation_list;
}
/**
* {@inheritdoc}
*/
public function prepareExecutionMetadataState(ExecutionMetadataStateInterface $metadata_state, ExpressionInterface $until = NULL, $apply_assertions = TRUE) {
if ($until && $this
->getUuid() === $until
->getUuid()) {
return TRUE;
}
$this
->prepareExecutionMetadataStateBeforeTraversal($metadata_state);
$apply_assertions = $apply_assertions && $this
->allowsMetadataAssertions();
foreach ($this as $child_expression) {
$found = $child_expression
->prepareExecutionMetadataState($metadata_state, $until, $apply_assertions);
// If the expression was found, we need to stop.
if ($found) {
return TRUE;
}
}
$this
->prepareExecutionMetadataStateAfterTraversal($metadata_state);
}
/**
* Prepares execution metadata state before traversing through children.
*
* @see ::prepareExecutionMetadataState()
* @see ::checkIntegrity()
*/
protected function prepareExecutionMetadataStateBeforeTraversal(ExecutionMetadataStateInterface $metadata_state) {
// Any pre-traversal preparations need to be added here.
}
/**
* Prepares execution metadata state after traversing through children.
*
* @see ::prepareExecutionMetadataState()
* @see ::checkIntegrity()
*/
protected function prepareExecutionMetadataStateAfterTraversal(ExecutionMetadataStateInterface $metadata_state) {
// Any post-traversal preparations need to be added here.
}
}
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 |
ExpressionContainerBase:: |
protected | property | The expression manager. | |
ExpressionContainerBase:: |
protected | property | The rules debug logger channel. | |
ExpressionContainerBase:: |
public | function |
Creates and adds an expression. Overrides ExpressionContainerInterface:: |
|
ExpressionContainerBase:: |
abstract protected | function | Determines whether child-expressions are allowed to assert metadata. | 4 |
ExpressionContainerBase:: |
public | function |
Verifies that this expression is configured correctly. Overrides ExpressionInterface:: |
1 |
ExpressionContainerBase:: |
public static | function | ||
ExpressionContainerBase:: |
public | function |
Prepares the execution metadata state by adding metadata to it. Overrides ExpressionInterface:: |
|
ExpressionContainerBase:: |
protected | function | Prepares execution metadata state after traversing through children. | 1 |
ExpressionContainerBase:: |
protected | function | Prepares execution metadata state before traversing through children. | 1 |
ExpressionContainerBase:: |
public static | function | Sorts an array of expressions by 'weight' property. | |
ExpressionContainerInterface:: |
public | function | Adds an expression object. | 3 |
ExpressionContainerInterface:: |
public | function | Deletes an expression identified by the specified UUID in the container. | 3 |
ExpressionContainerInterface:: |
public | function | Looks up the expression by UUID in this container. | 3 |
ExpressionInterface:: |
public | function | Execute the expression with a given Rules state. | 6 |
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. |