+ /**
+ * {@inheritdoc}
+ */
+ 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],
+ ];
+ $local_tasks["layout_builder.overrides.$entity_type_id.save"] = $base_plugin_definition + [
+ 'route_name' => "layout_builder.overrides.$entity_type_id.save",
+ 'title' => $this->t('Save Layout'),
+ 'parent_id' => "layout_builder_ui:layout_builder.overrides.$entity_type_id.view",
+ 'cache_contexts' => ['layout_builder_is_active:' . $entity_type_id],
+ ];
+ $local_tasks["layout_builder.overrides.$entity_type_id.cancel"] = $base_plugin_definition + [
+ 'route_name' => "layout_builder.overrides.$entity_type_id.cancel",
+ 'title' => $this->t('Cancel Layout'),
+ 'parent_id' => "layout_builder_ui:layout_builder.overrides.$entity_type_id.view",
+ 'weight' => 5,
+ 'cache_contexts' => ['layout_builder_is_active:' . $entity_type_id],
+ ];
+ // @todo This link should be conditionally displayed, see
+ // https://www.drupal.org/node/2917777.
+ $local_tasks["layout_builder.overrides.$entity_type_id.revert"] = $base_plugin_definition + [
+ 'route_name' => "layout_builder.overrides.$entity_type_id.revert",
+ 'title' => $this->t('Revert to defaults'),
+ 'parent_id' => "layout_builder_ui:layout_builder.overrides.$entity_type_id.view",
+ 'weight' => 10,
+ 'cache_contexts' => ['layout_builder_is_active:' . $entity_type_id],
+ ];
+ }
+ return $local_tasks;
+ }
+