diff --git a/core/lib/Drupal/Core/Menu/ContextualLinkManager.php b/core/lib/Drupal/Core/Menu/ContextualLinkManager.php index 26937ee..c8ccc34 100644 --- a/core/lib/Drupal/Core/Menu/ContextualLinkManager.php +++ b/core/lib/Drupal/Core/Menu/ContextualLinkManager.php @@ -18,7 +18,7 @@ use Drupal\Core\Plugin\Factory\ContainerFactory; /** - * Defines a plugin manager to deal with contextual links. + * Defines a contextual link plugin manager to deal with contextual links. * * @see \Drupal\Core\Menu\ContextualLinkInterface */ @@ -39,7 +39,7 @@ class ContextualLinkManager extends DefaultPluginManager { // The default link options. 'options' => array(), // The weight of the link. - 'weight' => NULL, + 'weight' => 0, // Default class for contextual link implementations. 'class' => '\Drupal\Core\Menu\ContextualLinkDefault', // The plugin id. Set by the plugin system based on the top-level YAML key. @@ -80,13 +80,14 @@ public function __construct(ControllerResolverInterface $controller_resolver, Mo */ public function processDefinition(&$definition, $plugin_id) { parent::processDefinition($definition, $plugin_id); + // If there is no route name, this is a broken definition. if (empty($definition['route_name'])) { - throw new PluginException(sprintf('Plugin (%s) definition must include "route_name"', $plugin_id)); + throw new PluginException(sprintf('Plugin (%s) definition must include "route_name".', $plugin_id)); } // If there is no group name, this is a broken definition. if (empty($definition['group'])) { - throw new PluginException(sprintf('Plugin (%s) definition must include "group"', $plugin_id)); + throw new PluginException(sprintf('Plugin (%s) definition must include "group".', $plugin_id)); } } @@ -97,7 +98,7 @@ public function processDefinition(&$definition, $plugin_id) { * The group name. * * @return array - * A list of contextual links plugin definitions, which should be shown. + * A list of contextual links plugin definitions. */ public function getContextualLinkPluginsByGroup($group_name) { if ($cache = $this->cacheBackend->get($this->cacheKey . ':' . $group_name)) { @@ -116,7 +117,7 @@ public function getContextualLinkPluginsByGroup($group_name) { } /** - * Gets the contextual links prepared as expected by theme_links. + * Gets the contextual links prepared as expected by theme_links(). * * @param string $group_name * The group name. diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 37f6e07..fc460d8 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -115,7 +115,6 @@ function block_menu() { $items['admin/structure/block/manage/%block/configure'] = array( 'title' => 'Configure block', 'type' => MENU_DEFAULT_LOCAL_TASK, - 'context' => MENU_CONTEXT_NONE, ); $items['admin/structure/block/add/%/%'] = array( 'title' => 'Place block', @@ -124,6 +123,7 @@ function block_menu() { ); // Block administration is tied to the theme and plugin definition so // that the plugin can appropriately attach to this URL structure. + // that the plugin can appropriately attach to this URL structure. // @todo D8: Use dynamic % arguments instead of static, hard-coded theme names // and plugin IDs to decouple the routes from these dependencies and allow // hook_menu_local_tasks() to check for the untranslated tab_parent path. diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module index e882e97..fe6a3ce 100644 --- a/core/modules/block/custom_block/custom_block.module +++ b/core/modules/block/custom_block/custom_block.module @@ -121,6 +121,7 @@ function custom_block_menu() { 'title' => 'Delete', 'weight' => 1, 'type' => MENU_LOCAL_TASK, + 'route_name' => 'custom_block.delete', ); return $items; } diff --git a/core/modules/contextual/contextual.module b/core/modules/contextual/contextual.module index 3829291..cee06c3 100644 --- a/core/modules/contextual/contextual.module +++ b/core/modules/contextual/contextual.module @@ -259,11 +259,11 @@ function contextual_pre_render_links($element) { $contextual_links_manager = \Drupal::service('plugin.manager.menu.contextual_link'); foreach ($element['#contextual_links'] as $module => $args) { - $result = $contextual_links_manager->getContextualLinksArrayByGroup($args[0], $args[1]); - if (!empty($result)) { + $contextual_links = $contextual_links_manager->getContextualLinksArrayByGroup($args[0], $args[1]); + if (!empty($contextual_links)) { unset($element['#contextual_links'][$module]); } - $items += $result; + $items += $contextual_links; } // @todo Remove once all contextual links are converted. @@ -319,9 +319,9 @@ function contextual_contextual_links_view_alter(&$element, $items) { * - menu:menu:menu=tools:|block:block:block=bartik.tools: * * So, expressed in a pattern: - * ::: + * ::: * - * The path args and options are encoded as query strings. + * The route parameters and options are encoded as query strings. * * @param array $contextual_links * The $element['#contextual_links'] value for some render element. @@ -333,10 +333,10 @@ function contextual_contextual_links_view_alter(&$element, $items) { function _contextual_links_to_id($contextual_links) { $ids = array(); foreach ($contextual_links as $module => $args) { - $parent_path = $args[0]; - $path_args = drupal_http_build_query($args[1]); - $metadata = drupal_http_build_query((isset($args[2])) ? $args[2] : array()); - $ids[] = "{$module}:{$parent_path}:{$path_args}:{$metadata}"; + $group = $args[0]; + $route_parameters = drupal_http_build_query($args[1]); + $options = drupal_http_build_query((isset($args[2])) ? $args[2] : array()); + $ids[] = "{$module}:{$group}:{$route_parameters}:{$options}"; } return implode('|', $ids); }