class RulesComponentActionDeriver in Rules 8.3
Derives Rules component action plugin definitions from config entities.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\rules\Plugin\RulesAction\RulesComponentActionDeriver implements ContainerDeriverInterface uses StringTranslationTrait
Expanded class hierarchy of RulesComponentActionDeriver
See also
\Drupal\rules\Plugin\RulesAction\RulesComponentAction
File
- src/
Plugin/ RulesAction/ RulesComponentActionDeriver.php, line 17
Namespace
Drupal\rules\Plugin\RulesActionView source
class RulesComponentActionDeriver extends DeriverBase implements ContainerDeriverInterface {
use StringTranslationTrait;
/**
* The config entity storage that holds Rules components.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $storage;
/**
* The Rules expression manager.
*
* @var \Drupal\rules\Engine\ExpressionManagerInterface
*/
protected $expressionManager;
/**
* Creates a new RulesComponentActionDeriver object.
*
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
* The entity storage.
* @param \Drupal\rules\Engine\ExpressionManagerInterface $expression_manager
* The Rules expression manager.
*/
public function __construct(EntityStorageInterface $storage, ExpressionManagerInterface $expression_manager) {
$this->storage = $storage;
$this->expressionManager = $expression_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('entity_type.manager')
->getStorage('rules_component'), $container
->get('plugin.manager.rules_expression'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$rules_components = $this->storage
->loadMultiple();
foreach ($rules_components as $rules_component) {
$component_config = $rules_component
->get('component');
$expression_definition = $this->expressionManager
->getDefinition($component_config['expression']['id']);
$this->derivatives[$rules_component
->id()] = [
'label' => $this
->t('@expression_type: @label', [
'@expression_type' => $expression_definition['label'],
'@label' => $rules_component
->label(),
]),
'category' => $this
->t('Components'),
'component_id' => $rules_component
->id(),
'context_definitions' => $rules_component
->getContextDefinitions(),
'provides' => $rules_component
->getProvidedContextDefinitions(),
] + $base_plugin_definition;
}
return $this->derivatives;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
RulesComponentActionDeriver:: |
protected | property | The Rules expression manager. | |
RulesComponentActionDeriver:: |
protected | property | The config entity storage that holds Rules components. | |
RulesComponentActionDeriver:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
RulesComponentActionDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
RulesComponentActionDeriver:: |
public | function | Creates a new RulesComponentActionDeriver object. | |
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. |