function MenuLinkContent::updateLink

Same name in other branches
  1. 9 core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php \Drupal\menu_link_content\Plugin\Menu\MenuLinkContent::updateLink()
  2. 8.9.x core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php \Drupal\menu_link_content\Plugin\Menu\MenuLinkContent::updateLink()
  3. 10 core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php \Drupal\menu_link_content\Plugin\Menu\MenuLinkContent::updateLink()

Overrides MenuLinkInterface::updateLink

File

core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php, line 253

Class

MenuLinkContent
Provides the menu link plugin for content menu links.

Namespace

Drupal\menu_link_content\Plugin\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) {
        $entity = $this->getEntity();
        foreach ($overrides as $key => $value) {
            $entity->{$key}->value = $value;
        }
        $entity->save();
    }
    return $this->pluginDefinition;
}

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