You are here

protected function EntityMenuLinkCloneForm::createMenuLinkClone in Menu Link Clone 8.2

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

Create menu links.

Parameters

object $menu_links_object_multiple: Menu Items Object.

Return value

array Retrun array with there menu items tree.

1 call to EntityMenuLinkCloneForm::createMenuLinkClone()
EntityMenuLinkCloneForm::cloneMenuLinks in src/Form/EntityMenuLinkCloneForm.php
Clone menu items.

File

src/Form/EntityMenuLinkCloneForm.php, line 240

Class

EntityMenuLinkCloneForm
Provides a menu link clone form.

Namespace

Drupal\menu_link_clone\Form

Code

protected function createMenuLinkClone($menu_links_object_multiple) {
  $result = FALSE;
  foreach ($menu_links_object_multiple as $id => $menu) {
    if (isset($id) && !empty($id)) {
      unset($menu['revision_id']);
      unset($menu['bundle']);
      $save_menu = MenuLinkContent::create($menu);
      $save_menu
        ->save();
      if ($save_menu) {
        $result = TRUE;
      }
    }
  }
  return $result;
}