You are here

public function ScheduledTransitionsLocalTasks::getDerivativeDefinitions in Scheduled Transitions 8

Same name and namespace in other branches
  1. 2.x src/Plugin/Derivative/ScheduledTransitionsLocalTasks.php \Drupal\scheduled_transitions\Plugin\Derivative\ScheduledTransitionsLocalTasks::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

src/Plugin/Derivative/ScheduledTransitionsLocalTasks.php, line 62

Class

ScheduledTransitionsLocalTasks
Scheduled transitions tab for entities.

Namespace

Drupal\scheduled_transitions\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  $this->derivatives = [];
  foreach ($this->entityTypeManager
    ->getDefinitions() as $entityType) {
    if ($entityType
      ->hasLinkTemplate(ScheduledTransitionsRouteProvider::LINK_TEMPLATE)) {
      $entityTypeId = $entityType
        ->id();
      $this->derivatives["{$entityTypeId}.scheduled_transitions"] = [
        'class' => ScheduledTransitionsLocalTask::class,
        'route_name' => ScheduledTransitionsRouteProvider::getScheduledTransitionRouteName($entityType),
        // Title is overridden by class.
        'title' => $this
          ->t('Scheduled transitions'),
        'base_route' => "entity.{$entityTypeId}.canonical",
        // Weight it after nodes' Edit, Delete, Versions.
        'weight' => 30,
      ] + $base_plugin_definition;
    }
  }
  return $this->derivatives;
}