function MenuLinkManager::resetInstance
Same name in other branches
- 9 core/lib/Drupal/Core/Menu/MenuLinkManager.php \Drupal\Core\Menu\MenuLinkManager::resetInstance()
- 10 core/lib/Drupal/Core/Menu/MenuLinkManager.php \Drupal\Core\Menu\MenuLinkManager::resetInstance()
- 11.x core/lib/Drupal/Core/Menu/MenuLinkManager.php \Drupal\Core\Menu\MenuLinkManager::resetInstance()
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.
2 calls to MenuLinkManager::resetInstance()
- MenuLinkManager::deleteLinksInMenu in core/
lib/ Drupal/ Core/ Menu/ MenuLinkManager.php - Deletes all links having a certain menu name.
- MenuLinkManager::resetLink in core/
lib/ Drupal/ Core/ Menu/ MenuLinkManager.php - Resets the values for a menu link based on the values found by discovery.
File
-
core/
lib/ Drupal/ Core/ Menu/ MenuLinkManager.php, line 394
Class
- MenuLinkManager
- Manages discovery, instantiation, and tree building of menu link plugins.
Namespace
Drupal\Core\MenuCode
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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.