You are here

public function StateChangeDeriver::getDerivativeDefinitions in Workbench Moderation Actions 8

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/Deriver/StateChangeDeriver.php, line 81

Class

StateChangeDeriver
Derives which moderation states are available.

Namespace

Drupal\workbench_moderation_actions\Plugin\Deriver

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  if (empty($this->derivatives)) {
    $plugin = $base_plugin_definition;
    $states = $this
      ->getAvailableStates();
    $entity_type_labels = $this
      ->getModeratedEntityTypeLabels();
    foreach ($entity_type_labels as $entity_type_id => $entity_label) {
      $plugin['type'] = $entity_type_id;
      foreach ($states as $state_id => $state) {
        $plugin['state'] = $state_id;
        $plugin['label'] = $this
          ->t('Set @entity_type_label as @state_label', [
          '@entity_type_label' => $entity_label,
          '@state_label' => $state
            ->label(),
        ]);
        $this->derivatives[$entity_type_id . '__' . $state_id] = $plugin;
      }
    }
  }
  return parent::getDerivativeDefinitions($base_plugin_definition);
}