function MenuLinkManager::createInstance

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

Returns a pre-configured menu link plugin instance.

Parameters

string $plugin_id: The ID of the plugin being instantiated.

array $configuration: An array of configuration relevant to the plugin instance.

Return value

\Drupal\Core\Menu\MenuLinkInterface A menu link instance.

Throws

\Drupal\Component\Plugin\Exception\PluginException If the instance cannot be created, such as if the ID is invalid.

8 calls to MenuLinkManager::createInstance()
MenuLinkManager::addDefinition in core/lib/Drupal/Core/Menu/MenuLinkManager.php
Adds a new menu link definition to the menu tree storage.
MenuLinkManager::deleteLinksInMenu in core/lib/Drupal/Core/Menu/MenuLinkManager.php
Deletes all links having a certain menu name.
MenuLinkManager::getInstance in core/lib/Drupal/Core/Menu/MenuLinkManager.php
MenuLinkManager::loadLinksByRoute in core/lib/Drupal/Core/Menu/MenuLinkManager.php
Loads multiple plugin instances based on route.
MenuLinkManager::removeDefinition in core/lib/Drupal/Core/Menu/MenuLinkManager.php
Removes a single link definition from the menu tree storage.

... See full list

File

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

Class

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

Namespace

Drupal\Core\Menu

Code

public function createInstance($plugin_id, array $configuration = []) {
    return $this->getFactory()
        ->createInstance($plugin_id, $configuration);
}

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