X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FMenu%2Fmenu.api.php;h=42e11867e37b6eefed0070c37c7358591b266153;hb=refs%2Fheads%2Fd864;hp=f932cf9bc4b618184e59738f2fd4034493ac2e32;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/lib/Drupal/Core/Menu/menu.api.php b/web/core/lib/Drupal/Core/Menu/menu.api.php index f932cf9bc..42e11867e 100644 --- a/web/core/lib/Drupal/Core/Menu/menu.api.php +++ b/web/core/lib/Drupal/Core/Menu/menu.api.php @@ -201,7 +201,7 @@ * // Finally, build a renderable array from the transformed tree. * $menu = $menu_tree->build($tree); * - * $menu_html = drupal_render($menu); + * $menu_html = \Drupal::service('renderer')->render($menu); * @endcode * * @} @@ -302,10 +302,12 @@ function hook_menu_links_discovered_alter(&$links) { * as described above. * @param string $route_name * The route name of the page. + * @param \Drupal\Core\Cache\RefinableCacheableDependencyInterface $cacheability + * The cacheability metadata for the current route's local tasks. * * @ingroup menu */ -function hook_menu_local_tasks_alter(&$data, $route_name) { +function hook_menu_local_tasks_alter(&$data, $route_name, \Drupal\Core\Cache\RefinableCacheableDependencyInterface &$cacheability) { // Add a tab linking to node/add to all pages. $data['tabs'][0]['node.add_page'] = [ @@ -320,6 +322,8 @@ function hook_menu_local_tasks_alter(&$data, $route_name) { ], ], ]; + // The tab we're adding is dependent on a user's access to add content. + $cacheability->addCacheTags(['user.permissions']); } /** @@ -446,7 +450,7 @@ function hook_system_breadcrumb_alter(\Drupal\Core\Breadcrumb\Breadcrumb &$bread * The following keys can be altered: * - text: The link text for the anchor tag. If the hook implementation * changes this text it needs to preserve the safeness of the original text. - * Using t() or \Drupal\Component\Utility\SafeMarkup::format() with + * Using t() or \Drupal\Component\Render\FormattableMarkup with * @placeholder is recommended as this will escape the original text if * necessary. If the resulting text is not marked safe it will be escaped. * - url_is_active: Whether or not the link points to the currently active