function MenuLinkManager::getDefinitions

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Menu/MenuLinkManager.php \Drupal\Core\Menu\MenuLinkManager::getDefinitions()
  2. 10 core/lib/Drupal/Core/Menu/MenuLinkManager.php \Drupal\Core\Menu\MenuLinkManager::getDefinitions()
  3. 11.x core/lib/Drupal/Core/Menu/MenuLinkManager.php \Drupal\Core\Menu\MenuLinkManager::getDefinitions()
1 call to MenuLinkManager::getDefinitions()
MenuLinkManager::rebuild in core/lib/Drupal/Core/Menu/MenuLinkManager.php
Triggers discovery, save, and cleanup of discovered links.

File

core/lib/Drupal/Core/Menu/MenuLinkManager.php, line 162

Class

MenuLinkManager
Manages discovery, instantiation, and tree building of menu link plugins.

Namespace

Drupal\Core\Menu

Code

public function getDefinitions() {
    // Since this function is called rarely, instantiate the discovery here.
    $definitions = $this->getDiscovery()
        ->getDefinitions();
    $this->moduleHandler
        ->alter('menu_links_discovered', $definitions);
    foreach ($definitions as $plugin_id => &$definition) {
        $definition['id'] = $plugin_id;
        $this->processDefinition($definition, $plugin_id);
    }
    // If this plugin was provided by a module that does not exist, remove the
    // plugin definition.
    // @todo Address what to do with an invalid plugin.
    //   https://www.drupal.org/node/2302623
    foreach ($definitions as $plugin_id => $plugin_definition) {
        if (!empty($plugin_definition['provider']) && !$this->moduleHandler
            ->moduleExists($plugin_definition['provider'])) {
            unset($definitions[$plugin_id]);
        }
    }
    return $definitions;
}

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