function MenuLinkDefault::updateLink

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

Overrides MenuLinkInterface::updateLink

File

core/lib/Drupal/Core/Menu/MenuLinkDefault.php, line 86

Class

MenuLinkDefault
Provides a default implementation for menu link plugins.

Namespace

Drupal\Core\Menu

Code

public function updateLink(array $new_definition_values, $persist) {
    // Filter the list of updates to only those that are allowed.
    $overrides = array_intersect_key($new_definition_values, $this->overrideAllowed);
    // Update the definition.
    $this->pluginDefinition = $overrides + $this->getPluginDefinition();
    if ($persist) {
        // Always save the menu name as an override to avoid defaulting to tools.
        $overrides['menu_name'] = $this->pluginDefinition['menu_name'];
        $this->staticOverride
            ->saveOverride($this->getPluginId(), $this->pluginDefinition);
    }
    return $this->pluginDefinition;
}

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