protected function MenuLinkManager::resetInstance

protected MenuLinkManager::resetInstance(MenuLinkInterface $instance)

Resets the menu link to its default settings.

Parameters

\Drupal\Core\Menu\MenuLinkInterface $instance: The menu link which should be reset.

Return value

\Drupal\Core\Menu\MenuLinkInterface The reset menu link.

Throws

\Drupal\Component\Plugin\Exception\PluginException Thrown when the menu link is not resettable.

File

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

Class

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

Namespace

Drupal\Core\Menu

Code

protected function resetInstance(MenuLinkInterface $instance) {
  $id = $instance->getPluginId();

  if (!$instance->isResettable()) {
    throw new PluginException("Menu link $id is not resettable");
  }
  // Get the original data from disk, reset the override and re-save the menu
  // tree for this link.
  $definition = $this->getDefinitions()[$id];
  $this->overrides->deleteOverride($id);
  $this->treeStorage->save($definition);
  return $this->createInstance($id);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Menu!MenuLinkManager.php/function/MenuLinkManager::resetInstance/8.1.x