public LocalTaskManager::getLocalTasks($route_name, $level = 0)
Collects the local tasks (tabs) for the current route.
string $route_name: The route for which to make renderable local tasks.
int $level: The level of tasks you ask for. Primary tasks are 0, secondary are 1.
array An array containing
Overrides LocalTaskManagerInterface::getLocalTasks
public function getLocalTasks($route_name, $level = 0) { if (!isset($this->taskData[$route_name])) { $cacheability = new CacheableMetadata(); $cacheability->addCacheContexts(['route']); // Look for route-based tabs. $this->taskData[$route_name] = [ 'tabs' => [], 'cacheability' => $cacheability, ]; if (!$this->requestStack->getCurrentRequest()->attributes->has('exception')) { // Safe to build tasks only when no exceptions raised. $data = []; $local_tasks = $this->getTasksBuild($route_name, $cacheability); foreach ($local_tasks as $tab_level => $items) { $data[$tab_level] = empty($data[$tab_level]) ? $items : array_merge($data[$tab_level], $items); } $this->taskData[$route_name]['tabs'] = $data; // Allow modules to alter local tasks. $this->moduleHandler->alter('menu_local_tasks', $this->taskData[$route_name], $route_name, $cacheability); $this->taskData[$route_name]['cacheability'] = $cacheability; } } if (isset($this->taskData[$route_name]['tabs'][$level])) { return [ 'tabs' => $this->taskData[$route_name]['tabs'][$level], 'route_name' => $route_name, 'cacheability' => $this->taskData[$route_name]['cacheability'], ]; } return [ 'tabs' => [], 'route_name' => $route_name, 'cacheability' => $this->taskData[$route_name]['cacheability'], ]; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Menu!LocalTaskManager.php/function/LocalTaskManager::getLocalTasks/8.1.x