You are here

public function Menu::save in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/src/Entity/Menu.php \Drupal\system\Entity\Menu::save()

Saves an entity permanently.

When saving existing entities, the entity is assumed to be complete, partial updates of entities are not supported.

Return value

int Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.

Throws

\Drupal\Core\Entity\EntityStorageException In case of failures an exception is thrown.

Overrides ConfigEntityBase::save

File

core/modules/system/src/Entity/Menu.php, line 99

Class

Menu
Defines the Menu configuration entity class.

Namespace

Drupal\system\Entity

Code

public function save() {
  $return = parent::save();
  \Drupal::cache('menu')
    ->invalidateAll();

  // Invalidate the block cache to update menu-based derivatives.
  if (\Drupal::moduleHandler()
    ->moduleExists('block')) {
    \Drupal::service('plugin.manager.block')
      ->clearCachedDefinitions();
  }
  return $return;
}