You are here

public function MenuLinkConfig::updateLink in Config menu link 8

@todo Simply storing the entity type ID in a variable would alleviate the need to override this entire method.

Overrides MenuLinkContent::updateLink

File

src/Plugin/Menu/MenuLinkConfig.php, line 167
Contains \Drupal\menu_link_config\Plugin\Menu\MenuLinkConfig.

Class

MenuLinkConfig
Provides a menu link plugin based upon storage in config.

Namespace

Drupal\menu_link_config\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;
    }
    $this->entityManager
      ->getStorage('menu_link_config')
      ->save($entity);
  }
  return $this->pluginDefinition;
}