public function menuLinkDependency($title, $link, $translations, $destBid, $weight = 0, $menu = 'main') {
    $menu_link_content = $this->entityManager->getStorage('menu_link_content')->create([
      'title' => $title,
      'link' => ['uri' => 'internal:/node/' . $destBid[0]],
      'menu_name' => (!empty($translations)) ? $menu . '-fr' : $menu,
      'langcode' => (!empty($translations)) ? 'fr' : 'en',
      'parent' => $link,
      'weight' => $weight,
    ]);
    $menu_link_content->save();
    $this->database->update('menu_link_content_data')
      ->fields(['link__uri' => 'entity:node/' . $destBid[0]])
      ->condition('id', $menu_link_content->id())
      ->execute();
    return $menu_link_content;
  }
public function menuLinkDependency($title, $link, $translations, $destBid, $weight = 0, $menu = 'main') {
    $menu_link_content = $this->entityManager->getStorage('menu_link_content')->create([
      'title' => $title,
      'link' => ['uri' => 'internal:/node/' . $destBid[0]],
      'menu_name' => (!empty($translations)) ? $menu . '-fr' : $menu,
      'langcode' => (!empty($translations)) ? 'fr' : 'en',
      'parent' => $link,
      'weight' => $weight,
    ]);
    $menu_link_content->save();
    $this->database->update('menu_link_content_data')
      ->fields(['link__uri' => 'entity:node/' . $destBid[0]])
      ->condition('id', $menu_link_content->id())
      ->execute();
    return $menu_link_content;
  }
public function menuLinkDependency ( $ title , $ link , $ translations , $ destBid , $ weight = 0 , $ menu = 'main' ) { $ menu_link_content = $ this -> entityManager -> getStorage ( 'menu_link_content' ) -> create ( [ 'title' => $ title , 'link' => [ 'uri' => 'internal:/node/' . $ destBid [ 0 ] ] , 'menu_name' => ( ! empty ( $ translations ) ) ? $ menu . '-fr' : $ menu , 'langcode' => ( ! empty ( $ translations ) ) ? 'fr' : 'en' , 'parent' => $ link , 'weight' => $ weight , ] ) ; $ menu_link_content -> save ( ) ; $ this -> database -> update ( 'menu_link_content_data' ) -> fields ( [ 'link__uri' => 'entity:node/' . $ destBid [ 0 ] ] ) -> condition ( 'id' , $ menu_link_content -> id ( ) ) -> execute ( ) ; return $ menu_link_content ; }
Add a menu link with dependency support.
Add a menu link with dependency support .