Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 

As a part of the new New Symfony-based routing system, the action link definitions are moving out of hook_menu() and into plugins implementing \Drupal\Core\Menu\LocalActionInterface. The primary discovery mechanism is YAML files following the naming pattern

A default implementation \Drupal\Core\Menu\LocalActionDefault is used unless another class is specified in the YAML file.

Drupal 7

<?php
function contact_menu() {
 
$items['admin/structure/contact'] = array(
   
'title' => 'Contact form',
   
'description' => 'Create a system contact form and set up categories for the form to use.',
   
'page callback' => 'contact_category_list',
   
'access arguments' => array('administer contact forms'),
   
'file' => 'contact.admin.inc',
  );
 
$items['admin/structure/contact/add'] = array(
   
'title' => 'Add category',
   
'page callback' => 'drupal_get_form',
   
'page arguments' => array('contact_category_edit_form'),
   
'access arguments' => array('administer contact forms'),
   
'type' => MENU_LOCAL_ACTION,
   
'weight' => 1,
   
'file' => 'contact.admin.inc',
  );
}
?>

Drupal 8

Local actions are defined in a YAML format, named after the module they are defined by ($modulename.local_actions.yml). See Providing module-defined actions.

Yaml File

contact_category_add_action:
  route_name: contact_category_add
  title: 'Add category'
  appears_on:
    - contact_category_list

Each local action is represented by a plugin with a definition from the YAML. Each local action definition contains four keys:
id: The machine name of the pluing
route_name: The machine name of the local action route.
title: The title of the local action. Will be passed on to t().
title_context: Optional context to pass on with the title to t().
appears_on: An array of route names for this action to be display on.

In order for a local action to be converted, both it and the path it appears on must first be converted to routes.
See #1971384: [META] Convert page callbacks to controllers for the list of issues and the WSCCI Conversion guide for instructions.

Note that the MENU_LOCAL_ACTION type did more than just present it as a local action, it also manipulated the breadcrumb trail and controlled which tabs appeared on its page. In order to preserve that behavior, a new constant was introduced, MENU_SIBLING_LOCAL_TASK.

Impacts: 
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done