You are here

public function RulesComponentActionDeriver::getDerivativeDefinitions in Rules 8.3

Gets the definition of all derivatives of a base plugin.

Parameters

array $base_plugin_definition: The definition array of the base plugin.

Return value

array An array of full derivative definitions keyed on derivative id.

Overrides DeriverBase::getDerivativeDefinitions

See also

getDerivativeDefinition()

File

src/Plugin/RulesAction/RulesComponentActionDeriver.php, line 60

Class

RulesComponentActionDeriver
Derives Rules component action plugin definitions from config entities.

Namespace

Drupal\rules\Plugin\RulesAction

Code

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;
}