diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 6f2f803..04f1f30 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -213,29 +213,6 @@ */ /** - * @defgroup menu_context_types Menu context types - * @{ - * Flags for use in the "context" attribute of menu router items. - */ - -/** - * Internal menu flag: Invisible local task. - * - * This flag may be used for local tasks like "Delete", so custom modules and - * themes can alter the default context and expose the task by altering menu. - */ -const MENU_CONTEXT_NONE = 0x0000; - -/** - * Internal menu flag: Local task should be displayed in page context. - */ -const MENU_CONTEXT_PAGE = 0x0001; - -/** - * @} End of "defgroup menu_context_types". - */ - -/** * @defgroup menu_status_codes Menu status codes * @{ * Status codes for menu callbacks. @@ -305,19 +282,16 @@ const MENU_PREFERRED_LINK = '1cf698d64d1aa4b83907cf6ed55db3a7f8e92c91'; /** - * Localizes the router item title using t() or another callback. + * Localizes a menu link title using t() if possible. * * Translate the title and description to allow storage of English title * strings in the database, yet display of them in the language required * by the current user. * * @param $item - * A menu router item or a menu link item. - * @param $link_translate - * TRUE if we are translating a menu link item; FALSE if we are - * translating a menu router item. + * A menu link entity. */ -function _menu_item_localize(&$item, $link_translate = FALSE) { +function _menu_item_localize(&$item) { // Allow default menu links to be translated. $item['localized_options'] = $item['options']; // All 'class' attributes are assumed to be an array during rendering, but @@ -328,22 +302,13 @@ function _menu_item_localize(&$item, $link_translate = FALSE) { if (isset($item['options']['attributes']['class']) && is_string($item['options']['attributes']['class'])) { $item['localized_options']['attributes']['class'] = explode(' ', $item['options']['attributes']['class']); } - // If we are translating the title of a menu link, and its title is the same - // as the corresponding router item, then we can use the title information - // from the router. If it's customized, then we need to use the link title - // itself; can't localize. - // If we are translating a router item (tabs, page, breadcrumb), then we - // can always use the information from the router item. - if (!$link_translate || !isset($item['link_title']) || ($item['title'] == $item['link_title'])) { - // t() is a special case. Since it is used very close to all the time, - // we handle it directly instead of using indirect, slower methods. - // @todo Recheck this line once https://drupal.org/node/2084421 is in. - $item['title'] = isset($item['link_title']) ? $item['link_title'] : $item['title']; + // If the menu link is defined in code and not customized, we can use t(). + if (!empty($item['machine_name']) && !$item['customized']) { // @todo Figure out a proper way to support translations of menu links, see // https://drupal.org/node/2193777. - $item['title'] = t($item['title']); + $item['title'] = t($item['link_title']); } - elseif ($link_translate) { + else { $item['title'] = $item['link_title']; } } @@ -390,7 +355,7 @@ function _menu_link_translate(&$item) { } // For performance, don't localize a link the user can't access. if ($item['access']) { - _menu_item_localize($item, TRUE); + _menu_item_localize($item); } } @@ -632,7 +597,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = // Check if the active trail has been overridden for this menu tree. $active_path = menu_tree_get_path($menu_name); - // Load the router item corresponding to the current page. + // Load the request corresponding to the current page. $request = \Drupal::request(); $system_path = NULL; if ($route_name = $request->attributes->get(RouteObjectInterface::ROUTE_NAME)) { diff --git a/core/lib/Drupal/Core/EventSubscriber/RouterRebuildSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/RouterRebuildSubscriber.php index 0d59329..98bf05c 100644 --- a/core/lib/Drupal/Core/EventSubscriber/RouterRebuildSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/RouterRebuildSubscriber.php @@ -17,7 +17,7 @@ use Symfony\Component\HttpKernel\KernelEvents; /** - * Rebuilds the router and runs menu-specific code if necessary. + * Rebuilds the default menu links and runs menu-specific code if necessary. */ class RouterRebuildSubscriber implements EventSubscriberInterface { @@ -55,20 +55,20 @@ public function onKernelTerminate(PostResponseEvent $event) { } /** - * Rebuilds the menu_router and deletes the local_task cache tag. + * Rebuilds the menu links and deletes the local_task cache tag. * * @param \Symfony\Component\EventDispatcher\Event $event * The event object. */ public function onRouterRebuild(Event $event) { - $this->menuRouterRebuild(); + $this->menuLinksRebuild(); Cache::deleteTags(array('local_task' => 1)); } /** * Perform menu-specific rebuilding. */ - protected function menuRouterRebuild() { + protected function menuLinksRebuild() { if ($this->lock->acquire(__FUNCTION__)) { $transaction = db_transaction(); try {