You are here

public function OverridesSectionStorage::buildLocalTasks in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php \Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage::buildLocalTasks()

Provides the local tasks dynamically for Layout Builder plugins.

Parameters

mixed $base_plugin_definition: The definition of the base plugin.

Return value

array An array of full derivative definitions keyed on derivative ID.

Overrides SectionStorageLocalTaskProviderInterface::buildLocalTasks

File

core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php, line 279

Class

OverridesSectionStorage
Defines the 'overrides' section storage type.

Namespace

Drupal\layout_builder\Plugin\SectionStorage

Code

public function buildLocalTasks($base_plugin_definition) {
  $local_tasks = [];
  foreach ($this
    ->getEntityTypes() as $entity_type_id => $entity_type) {
    $local_tasks["layout_builder.overrides.{$entity_type_id}.view"] = $base_plugin_definition + [
      'route_name' => "layout_builder.overrides.{$entity_type_id}.view",
      'weight' => 15,
      'title' => $this
        ->t('Layout'),
      'base_route' => "entity.{$entity_type_id}.canonical",
      'cache_contexts' => [
        'layout_builder_is_active:' . $entity_type_id,
      ],
    ];
  }
  return $local_tasks;
}