function menu_primary_local_tasks in Drupal 8
Same name and namespace in other branches
- 4 includes/menu.inc \menu_primary_local_tasks()
- 5 includes/menu.inc \menu_primary_local_tasks()
- 6 includes/menu.inc \menu_primary_local_tasks()
- 7 includes/menu.inc \menu_primary_local_tasks()
Returns the rendered local tasks at the top level.
Deprecated
in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Menu\LocalTaskManagerInterface::getLocalTasks() instead.
See also
https://www.drupal.org/node/2874695
Related topics
2 calls to menu_primary_local_tasks()
- MenuLegacyTest::testPrimaryLocalTasks in core/
tests/ Drupal/ KernelTests/ Core/ Menu/ MenuLegacyTest.php - Tests deprecation of the menu_primary_local_tasks() function.
- menu_local_tabs in core/
includes/ menu.inc - Returns a renderable element for the primary and secondary tabs.
File
- core/
includes/ menu.inc, line 125 - API for the Drupal menu system.
Code
function menu_primary_local_tasks() {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \\Drupal\\Core\\Menu\\LocalTaskManagerInterface::getLocalTasks() instead. See https://www.drupal.org/node/2874695', E_USER_DEPRECATED);
/** @var \Drupal\Core\Menu\LocalTaskManagerInterface $manager */
$manager = \Drupal::service('plugin.manager.menu.local_task');
$links = $manager
->getLocalTasks(\Drupal::routeMatch()
->getRouteName(), 0);
// Do not display single tabs.
return count(Element::getVisibleChildren($links['tabs'])) > 1 ? $links['tabs'] : '';
}