You are here

protected function EntityMenuLinkCloneForm::cloneMenuLinks in Menu Link Clone 8

Same name and namespace in other branches
  1. 8.3 src/Form/EntityMenuLinkCloneForm.php \Drupal\menu_link_clone\Form\EntityMenuLinkCloneForm::cloneMenuLinks()
  2. 8.2 src/Form/EntityMenuLinkCloneForm.php \Drupal\menu_link_clone\Form\EntityMenuLinkCloneForm::cloneMenuLinks()

Clone menu items.

Parameters

object $source_menu_name: Source menu name from we need to clone the menu items.

string $target_menu_name: Destination menu name to clone the menu items.

1 call to EntityMenuLinkCloneForm::cloneMenuLinks()
EntityMenuLinkCloneForm::submitForm in src/Form/EntityMenuLinkCloneForm.php
Form submission handler.

File

src/Form/EntityMenuLinkCloneForm.php, line 71

Class

EntityMenuLinkCloneForm
Provides a menu link clone form.

Namespace

Drupal\menu_link_clone\Form

Code

protected function cloneMenuLinks($source_menu_name, $target_menu_name) {
  $result = FALSE;
  $menuLinkIds = $this
    ->getMenuItemIds($source_menu_name);
  if ($menuLinkIds['status']) {
    $menuLinks = MenuLinkContent::loadMultiple($menuLinkIds['items']);
    $data = $this
      ->resetLinkItems($menuLinks);
    $data = $this
      ->setUuidForMenuItems($data, $target_menu_name);
    $data = $this
      ->createMenuLinkClone($data);
    if ($data) {
      $result = TRUE;
    }
  }
  return $result;
}