You are here

public function AutoEntityLabelConfigTask::getDerivativeDefinitions in Automatic Entity Label 8.3

Same name and namespace in other branches
  1. 8 src/Plugin/Derivative/AutoEntityLabelConfigTask.php \Drupal\auto_entitylabel\Plugin\Derivative\AutoEntityLabelConfigTask::getDerivativeDefinitions()
  2. 8.2 src/Plugin/Derivative/AutoEntityLabelConfigTask.php \Drupal\auto_entitylabel\Plugin\Derivative\AutoEntityLabelConfigTask::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/AutoEntityLabelConfigTask.php, line 47

Class

AutoEntityLabelConfigTask
Class for Config Task.

Namespace

Drupal\auto_entitylabel\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  $this->derivatives = [];
  foreach ($this->entityTypeManager
    ->getDefinitions() as $entity_type_id => $entity_type) {

    // Special handling of Taxonomy. See https://www.drupal.org/node/2822546
    if ($entity_type_id == "taxonomy_vocabulary") {
      $base_route = "entity.{$entity_type_id}.overview_form";
    }
    else {
      $base_route = "entity.{$entity_type_id}.edit_form";
    }
    if ($entity_type
      ->hasLinkTemplate('auto-label')) {
      $this->derivatives["{$entity_type_id}.auto_label_tab"] = [
        'route_name' => "entity.{$entity_type_id}.auto_label",
        'title' => $this
          ->t('Automatic label'),
        'base_route' => $base_route,
        'weight' => 100,
      ];
    }
  }
  foreach ($this->derivatives as &$entry) {
    $entry += $base_plugin_definition;
  }
  return $this->derivatives;
}