function MenuLinkManager::updateDefinition

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

Updates the values for a menu link definition in the menu tree storage.

This will update the definition for a discovered menu link without the need for a full rebuild. It is also used for plugins not found through discovery to update definitions.

Parameters

string $id: The menu link plugin ID.

array $new_definition_values: The new values for the link definition. This will usually be just a subset of the plugin definition.

bool $persist: TRUE to also have the link instance itself persist the changed values to any additional storage by invoking MenuLinkInterface::updateDefinition() on the plugin that is being updated.

Return value

\Drupal\Core\Menu\MenuLinkInterface A plugin instance created using the updated definition.

Overrides MenuLinkManagerInterface::updateDefinition

File

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

Class

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

Namespace

Drupal\Core\Menu

Code

public function updateDefinition($id, array $new_definition_values, $persist = TRUE) {
    $instance = $this->createInstance($id);
    if ($instance) {
        $new_definition_values['id'] = $id;
        $changed_definition = $instance->updateLink($new_definition_values, $persist);
        $this->treeStorage
            ->save($changed_definition);
    }
    return $instance;
}

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