function ContextualLinkManager::getContextualLinkPluginsByGroup

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

Overrides ContextualLinkManagerInterface::getContextualLinkPluginsByGroup

1 call to ContextualLinkManager::getContextualLinkPluginsByGroup()
ContextualLinkManager::getContextualLinksArrayByGroup in core/lib/Drupal/Core/Menu/ContextualLinkManager.php
Gets the contextual links prepared as expected by links.html.twig.

File

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

Class

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

Namespace

Drupal\Core\Menu

Code

public function getContextualLinkPluginsByGroup($group_name) {
    if (isset($this->pluginsByGroup[$group_name])) {
        $contextual_links = $this->pluginsByGroup[$group_name];
    }
    elseif ($cache = $this->cacheBackend
        ->get($this->cacheKey . ':' . $group_name)) {
        $contextual_links = $cache->data;
        $this->pluginsByGroup[$group_name] = $contextual_links;
    }
    else {
        $contextual_links = [];
        foreach ($this->getDefinitions() as $plugin_id => $plugin_definition) {
            if ($plugin_definition['group'] == $group_name) {
                $contextual_links[$plugin_id] = $plugin_definition;
            }
        }
        $this->cacheBackend
            ->set($this->cacheKey . ':' . $group_name, $contextual_links);
        $this->pluginsByGroup[$group_name] = $contextual_links;
    }
    return $contextual_links;
}

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