diff --git a/core/lib/Drupal/Core/Menu/LocalActionDefault.php b/core/lib/Drupal/Core/Menu/LocalActionDefault.php index 413938a..662169f 100644 --- a/core/lib/Drupal/Core/Menu/LocalActionDefault.php +++ b/core/lib/Drupal/Core/Menu/LocalActionDefault.php @@ -15,9 +15,7 @@ use Symfony\Component\HttpFoundation\Request; /** - * Provides defaults implement of local action plugins. - * - * @todo This class needs more documentation and/or @see references. + * Provides a default implementation for local action plugins. */ class LocalActionDefault extends PluginBase implements LocalActionInterface, ContainerFactoryPluginInterface { @@ -88,6 +86,13 @@ public function getTitle() { /** * {@inheritdoc} */ + public function getWeight() { + return $this->pluginDefinition['weight']; + } + + /** + * {@inheritdoc} + */ public function getRouteParameters(Request $request) { $parameters = isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : array(); $route = $this->routeProvider->getRouteByName($this->getRouteName()); @@ -99,7 +104,6 @@ public function getRouteParameters(Request $request) { // slugs in the path patterns. For example, if the route's path pattern is // /filter/tips/{filter_format} and the path is /filter/tips/plain_text then // $raw_variables->get('filter_format') == 'plain_text'. - $raw_variables = $request->attributes->get('_raw_variables'); foreach ($variables as $name) { diff --git a/core/lib/Drupal/Core/Menu/LocalActionInterface.php b/core/lib/Drupal/Core/Menu/LocalActionInterface.php index 75841de..152b3c6 100644 --- a/core/lib/Drupal/Core/Menu/LocalActionInterface.php +++ b/core/lib/Drupal/Core/Menu/LocalActionInterface.php @@ -37,8 +37,9 @@ public function getRouteParameters(Request $request); /** * Returns the weight for the local action. + * + * @return int */ - public function getPath(); public function getWeight(); /** diff --git a/core/lib/Drupal/Core/Menu/LocalActionManager.php b/core/lib/Drupal/Core/Menu/LocalActionManager.php index 1013f8f..e5fbf3b 100644 --- a/core/lib/Drupal/Core/Menu/LocalActionManager.php +++ b/core/lib/Drupal/Core/Menu/LocalActionManager.php @@ -38,11 +38,13 @@ class LocalActionManager extends DefaultPluginManager { */ protected $defaults = array( // The plugin id. Set by the plugin system based on the top-level YAML key. - 'id' => '', + 'id' => NULL, // The static title for the local action. 'title' => '', + // The weight of the local action. + 'weight' => 0, // (Required) the route name used to generate a link. - 'route_name' => '', + 'route_name' => NULL, // Default route parameters for generating links. 'route_parameters' => array(), // Associative array of link options. @@ -163,7 +165,9 @@ public function getActionsForRoute($route_appears) { } // Pre-fetch all the action route objects. This reduces the number of SQL // queries that would otherwise be triggered by the access manager. - $this->routeProvider->getRoutesByNames($route_names); + if (!empty($route_names)) { + $this->routeProvider->getRoutesByNames($route_names); + } } $links = array(); foreach ($this->instances[$route_appears] as $plugin) { @@ -178,6 +182,7 @@ public function getActionsForRoute($route_appears) { 'localized_options' => $plugin->getOptions($this->request), ), '#access' => $this->accessManager->checkNamedRoute($route_name, $route_parameters), + '#weight' => $plugin->getWeight(), ); } return $links;