You are here

public function TaxonomyMenuMenuLink::updateLink in Taxonomy menu 8.3

Updates the definition values for a menu link.

Depending on the implementation details of the class, not all definition values may be changed. For example, changes to the title of a static link will be discarded.

In general, this method should not be called directly, but will be called automatically from MenuLinkManagerInterface::updateDefinition().

Parameters

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 have the link persist the changed values to any additional storage.

Return value

array The plugin definition incorporating any allowed changes.

Overrides MenuLinkInterface::updateLink

File

src/Plugin/Menu/TaxonomyMenuMenuLink.php, line 137

Class

TaxonomyMenuMenuLink
Defines menu links provided by taxonomy menu.

Namespace

Drupal\taxonomy_menu\Plugin\Menu

Code

public function updateLink(array $new_definition_values, $persist) {
  $overrides = array_intersect_key($new_definition_values, $this->overrideAllowed);

  // Update the definition.
  $this->pluginDefinition = $overrides + $this->pluginDefinition;
  if ($persist) {

    // TODO - consider any "persistence" back to TaxonomyMenu and/or Taxonomy
    // upon menu link update.
    // 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;
}