diff -u b/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module --- b/core/modules/block/custom_block/custom_block.module +++ b/core/modules/block/custom_block/custom_block.module @@ -38,25 +38,6 @@ } /** - * Implements hook_menu_local_tasks(). - */ -function custom_block_menu_local_tasks(&$data, $route_name) { - if ($route_name == 'custom_block.list') { - // @todo Move to a LocalAction plugin when https://drupal.org/node/2045267 - // allows local actions to work with query strings. - $item = menu_get_item('block/add'); - if ($item['access']) { - // Add a destination parameter. - $item['localized_options']['query']['destination'] = 'admin/structure/block/custom-blocks'; - $data['actions']['block/add'] = array( - '#theme' => 'menu_local_action', - '#link' => $item, - ); - } - } -} - -/** * Implements hook_menu_link_defaults(). */ function custom_block_menu_link_defaults() { only in patch2: unchanged: --- a/core/modules/block/custom_block/custom_block.local_actions.yml +++ b/core/modules/block/custom_block/custom_block.local_actions.yml @@ -10,5 +10,5 @@ custom_block_add_action: appears_on: - block.admin_display - block.admin_display_theme + - custom_block.list class: \Drupal\custom_block\Plugin\Menu\LocalAction\CustomBlockAddLocalAction - only in patch2: unchanged: --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Menu/LocalAction/CustomBlockAddLocalAction.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Menu/LocalAction/CustomBlockAddLocalAction.php @@ -8,6 +8,7 @@ namespace Drupal\custom_block\Plugin\Menu\LocalAction; use Drupal\Core\Menu\LocalActionDefault; +use Symfony\Cmf\Component\Routing\RouteObjectInterface; use Symfony\Component\HttpFoundation\Request; /** @@ -24,6 +25,10 @@ public function getOptions(Request $request) { if ($request->attributes->has('theme')) { $options['query']['theme'] = $request->attributes->get('theme'); } + // Adds a destination on custom block listing. + if ($request->attributes->get(RouteObjectInterface::ROUTE_NAME) == 'custom_block.list') { + $options['query']['destination'] = 'admin/structure/block/custom-blocks'; + } return $options; }