function ContextualLinkManager::getContextualLinksArrayByGroup

Same name in other branches
  1. 9 core/lib/Drupal/Core/Menu/ContextualLinkManager.php \Drupal\Core\Menu\ContextualLinkManager::getContextualLinksArrayByGroup()
  2. 8.9.x core/lib/Drupal/Core/Menu/ContextualLinkManager.php \Drupal\Core\Menu\ContextualLinkManager::getContextualLinksArrayByGroup()
  3. 11.x core/lib/Drupal/Core/Menu/ContextualLinkManager.php \Drupal\Core\Menu\ContextualLinkManager::getContextualLinksArrayByGroup()

File

core/lib/Drupal/Core/Menu/ContextualLinkManager.php, line 174

Class

ContextualLinkManager
Defines a contextual link plugin manager to deal with contextual links.

Namespace

Drupal\Core\Menu

Code

public function getContextualLinksArrayByGroup($group_name, array $route_parameters, array $metadata = []) {
    $links = [];
    $request = $this->requestStack
        ->getCurrentRequest();
    foreach ($this->getContextualLinkPluginsByGroup($group_name) as $plugin_id => $plugin_definition) {
        
        /** @var \Drupal\Core\Menu\ContextualLinkInterface $plugin */
        $plugin = $this->createInstance($plugin_id);
        $route_name = $plugin->getRouteName();
        // Check access.
        if (!$this->accessManager
            ->checkNamedRoute($route_name, $route_parameters, $this->account)) {
            continue;
        }
        $links[$plugin_id] = [
            'route_name' => $route_name,
            'route_parameters' => $route_parameters,
            'title' => $plugin->getTitle($request),
            'weight' => $plugin->getWeight(),
            'localized_options' => $plugin->getOptions(),
            'metadata' => $metadata,
        ];
    }
    $this->moduleHandler
        ->alter('contextual_links', $links, $group_name, $route_parameters);
    return $links;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.