You are here

public function MenuTreeStorage::save in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::save()

Saves a plugin definition to the storage.

Parameters

array $definition: A definition for a \Drupal\Core\Menu\MenuLinkInterface plugin.

Return value

array The menu names affected by the save operation. This will be one menu name if the link is saved to the sane menu, or two if it is saved to a new menu.

Throws

\Exception Thrown if the storage back-end does not exist and could not be created.

\Drupal\Component\Plugin\Exception\PluginException Thrown if the definition is invalid - for example, if the specified parent would cause the links children to be moved to greater than the maximum depth.

Overrides MenuTreeStorageInterface::save

2 calls to MenuTreeStorage::save()
MenuTreeStorage::delete in core/lib/Drupal/Core/Menu/MenuTreeStorage.php
Deletes a menu link definition from the storage.
MenuTreeStorage::purgeMultiple in core/lib/Drupal/Core/Menu/MenuTreeStorage.php
Purges multiple menu links that no longer exist.

File

core/lib/Drupal/Core/Menu/MenuTreeStorage.php, line 257

Class

MenuTreeStorage
Provides a menu tree storage using the database.

Namespace

Drupal\Core\Menu

Code

public function save(array $link) {
  $affected_menus = $this
    ->doSave($link);
  $this
    ->resetDefinitions();
  $cache_tags = Cache::buildTags('config:system.menu', $affected_menus, '.');
  $this->cacheTagsInvalidator
    ->invalidateTags($cache_tags);
  return $affected_menus;
}