diff -u b/core/includes/menu.inc b/core/includes/menu.inc
--- b/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -1742,7 +1742,8 @@
$link['localized_options']['attributes']['class'][] = 'button-action';
$output = '
';
- if (!empty($link['route_name'])) {
+ // @todo Remove the is_plugin check once
+ if (!empty($link['route_name']) && !empty($link['is_plugin'])) {
$output .= Drupal::l($link['title'], $link['route_name'], $link['route_parameters'], $link['localized_options']);
}
else {
@@ -2313,7 +2314,7 @@
*/
function menu_get_local_actions() {
$links = menu_local_tasks();
- $route_name = Drupal::request()->attributes->get('_route');
+ $route_name = Drupal::request()->attributes->get(RouteObjectInterface::ROUTE_NAME);
$manager = Drupal::service('plugin.manager.menu.local_action');
$links['actions'] += $manager->getActionsForRoute($route_name);
return $links['actions'];
diff -u b/core/lib/Drupal/Core/Menu/LocalActionManager.php b/core/lib/Drupal/Core/Menu/LocalActionManager.php
--- b/core/lib/Drupal/Core/Menu/LocalActionManager.php
+++ b/core/lib/Drupal/Core/Menu/LocalActionManager.php
@@ -31,20 +31,25 @@
*/
class LocalActionManager extends DefaultPluginManager {
+ /**
+ * Provides some default values for all local action plugin.s
+ *
+ * @var array
+ */
protected $defaults = array(
// The ID.
'id' => '',
- // The static title for the local task.
+ // The static title for the local action.
'title' => '',
// (Required) the route name used to generate a link.
'route_name' => '',
- // Default reoute parameters for generating links.
+ // Default route parameters for generating links.
'route_parameters' => array(),
// Associative array of link options.
'options' => array(),
// The route names where this local action appears.
'appears_on' => array(),
- // Default class for local task implementations.
+ // Default class for local action implementations.
'class' => 'Drupal\Core\Menu\LocalActionBase',
);
@@ -86,20 +91,21 @@
/**
* Constructs a LocalActionManager object.
*
- * @param \Traversable $namespaces
- * An object that implements \Traversable which contains the root paths
- * keyed by the corresponding namespace to look for plugin implementations.
* @param \Symfony\Component\HttpKernel\Controller\ControllerResolverInterface $controller_resolver
* An object to use in introspecting route methods.
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object to use for building titles and paths for plugin
* instances.
+ * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
+ * The route provider.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Language\LanguageManager $language_manager
* The language manager.
+ * @param \Drupal\Core\Access\AccessManager $access_manager
+ * The access manager.
*/
public function __construct(ControllerResolverInterface $controller_resolver, Request $request, RouteProviderInterface $route_provider, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend, LanguageManager $language_manager, AccessManager $access_manager) {
// Skip calling the parent constructor, since that assumes annontation-based discovery
@@ -168,6 +174,7 @@
'route_name' => $route_name,
'route_parameters' => $route_parameters,
'localized_options' => $plugin->getOptions($this->request),
+ 'is_plugin' => TRUE,
),
'#access' => $this->accessManager->checkNamedRoute($route_name, $route_parameters),
);
only in patch2:
unchanged:
--- a/core/modules/block/custom_block/custom_block.module
+++ b/core/modules/block/custom_block/custom_block.module
@@ -50,10 +50,10 @@ function custom_block_menu_local_tasks(&$data, $router_item, $root_path) {
* Implements hook_menu_local_actions_alter().
*/
function custom_block_menu_local_actions_alter(&$actions) {
- if (isset($actions['local_action_static:custom_block_add_action'])) {
+ if (isset($actions['custom_block_add_action'])) {
foreach (list_themes() as $theme => $theme_info) {
if ($theme_info->status) {
- $actions['local_action_static:custom_block_add_action']['appears_on'][] = "block_admin_display.$theme";
+ $actions['custom_block_add_action']['appears_on'][] = "block_admin_display.$theme";
}
}
}
only in patch2:
unchanged:
--- a/core/modules/menu/menu.module
+++ b/core/modules/menu/menu.module
@@ -91,11 +91,6 @@ function menu_menu() {
'title callback' => 'entity_page_label',
'title arguments' => array(4),
);
- $items['admin/structure/menu/manage/%menu/add'] = array(
- 'title' => 'Add link',
- 'route_name' => 'menu_link_add',
- 'type' => MENU_LOCAL_ACTION,
- );
$items['admin/structure/menu/manage/%menu/edit'] = array(
'title' => 'Edit menu',
'type' => MENU_DEFAULT_LOCAL_TASK,