function ContextualLinkManager::getContextualLinkPluginsByGroup

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

File

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

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.