You are here

public function TaxonomyMenu::save in Taxonomy menu 8.3

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

src/Entity/TaxonomyMenu.php, line 170

Class

TaxonomyMenu
Defines the TaxonomyMenu entity.

Namespace

Drupal\taxonomy_menu\Entity

Code

public function save() {

  // Make sure we don't have any save exceptions before building menu
  // definitions.
  $return = parent::save();
  foreach ($this
    ->getLinks([], TRUE) as $link_key => $link_def) {
    if ($this
      ->isNew() || !$this
      ->getMenuLinkManager()
      ->hasDefinition($link_key)) {
      $this
        ->getMenuLinkManager()
        ->addDefinition($link_key, $link_def);
    }
    else {
      $this
        ->getMenuLinkManager()
        ->updateDefinition($link_key, $link_def);
    }
  }
  return $return;
}