function menu_link_save

Saves a menu link.

After calling this function, rebuild the menu cache using menu_cache_clear_all().

Parameters

\Drupal\menu_link\Plugin\Core\Entity\MenuLink $menu_link: The menu link entity to be saved.

Return value

int|bool Returns SAVED_NEW or SAVED_UPDATED if the save operation succeeded, or FALSE if it failed.

10 calls to menu_link_save()
LinksTest::assertMenuLinkParents in drupal/core/modules/system/lib/Drupal/system/Tests/Menu/LinksTest.php
Assert that at set of links is properly parented.
LinksTest::testMenuLinkReparenting in drupal/core/modules/system/lib/Drupal/system/Tests/Menu/LinksTest.php
Test automatic reparenting of menu links.
LinksTest::testMenuLinkRouterReparenting in drupal/core/modules/system/lib/Drupal/system/Tests/Menu/LinksTest.php
Test automatic reparenting of menu links derived from menu routers.
MenuNodeTest::testMenuNodeFormWidget in drupal/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php
Test creating, editing, deleting menu links via node form widget.
MenuRouterTest::testMenuLinkOptions in drupal/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php
Test menu link 'options' storage and rendering.

... See full list

File

drupal/core/modules/menu_link/menu_link.module, line 123
Enables users to create menu links.

Code

function menu_link_save(MenuLink $menu_link) {
  return $menu_link
    ->save();
}