You are here

public function FieldUiLocalTask::alterLocalTasks in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php \Drupal\field_ui\Plugin\Derivative\FieldUiLocalTask::alterLocalTasks()

Alters the base_route definition for field_ui local tasks.

Parameters

array $local_tasks: An array of local tasks plugin definitions, keyed by plugin ID.

File

core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php, line 175
Contains \Drupal\field_ui\Plugin\Derivative\FieldUiLocalTask.

Class

FieldUiLocalTask
Provides local task definitions for all entity bundles.

Namespace

Drupal\field_ui\Plugin\Derivative

Code

public function alterLocalTasks(&$local_tasks) {
  foreach ($this->entityManager
    ->getDefinitions() as $entity_type_id => $entity_type) {
    if ($route_name = $entity_type
      ->get('field_ui_base_route')) {
      $local_tasks["field_ui.fields:overview_{$entity_type_id}"]['base_route'] = $route_name;
      $local_tasks["field_ui.fields:form_display_overview_{$entity_type_id}"]['base_route'] = $route_name;
      $local_tasks["field_ui.fields:display_overview_{$entity_type_id}"]['base_route'] = $route_name;
      $local_tasks["field_ui.fields:field_form_display_default_{$entity_type_id}"]['base_route'] = $route_name;
      $local_tasks["field_ui.fields:field_display_default_{$entity_type_id}"]['base_route'] = $route_name;
      foreach ($this->entityManager
        ->getFormModes($entity_type_id) as $form_mode => $form_mode_info) {
        $local_tasks['field_ui.fields:field_form_display_' . $form_mode . '_' . $entity_type_id]['base_route'] = $route_name;
      }
      foreach ($this->entityManager
        ->getViewModes($entity_type_id) as $view_mode => $form_mode_info) {
        $local_tasks['field_ui.fields:field_display_' . $view_mode . '_' . $entity_type_id]['base_route'] = $route_name;
      }
    }
  }
}