You are here

public function LocalTasks::getDerivativeDefinitions in RNG - Events and Registrations 8

Same name in this branch
  1. 8 src/Plugin/Derivative/LocalTasks.php \Drupal\rng\Plugin\Derivative\LocalTasks::getDerivativeDefinitions()
  2. 8 rng_debug/src/Plugin/Derivative/LocalTasks.php \Drupal\rng_debug\Plugin\Derivative\LocalTasks::getDerivativeDefinitions()
Same name and namespace in other branches
  1. 8.2 rng_debug/src/Plugin/Derivative/LocalTasks.php \Drupal\rng_debug\Plugin\Derivative\LocalTasks::getDerivativeDefinitions()
  2. 3.x rng_debug/src/Plugin/Derivative/LocalTasks.php \Drupal\rng_debug\Plugin\Derivative\LocalTasks::getDerivativeDefinitions()

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

rng_debug/src/Plugin/Derivative/LocalTasks.php, line 49

Class

LocalTasks
Provides dynamic tasks.

Namespace

Drupal\rng_debug\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  $this->derivatives = [];
  $event_types = $this->eventManager
    ->getEventTypes();
  foreach (array_keys($event_types) as $entity_type) {

    // Only need one set of tasks task per entity type.
    if ($this->routeProvider
      ->getRouteByName("entity.{$entity_type}.canonical")) {
      $event_default = "rng.event.{$entity_type}.event.default";
      $this->derivatives["rng.event.{$entity_type}.event.rules"] = array(
        'title' => t('Rules'),
        'route_name' => "rng.event.{$entity_type}.rules",
        'parent_id' => 'rng.local_tasks:' . $event_default,
        'weight' => 20,
      );
    }
  }
  foreach ($this->derivatives as &$entry) {
    $entry += $base_plugin_definition;
  }
  return parent::getDerivativeDefinitions($base_plugin_definition);
}