You are here

protected function EntityMenuLinkCloneForm::getMenuItems 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::getMenuItems()

Get menu items ids.

Parameters

string $menu_id: Menu name for which we can get there items.

Return value

array Retrun array with there menu items tree.

2 calls to EntityMenuLinkCloneForm::getMenuItems()
EntityMenuLinkCloneForm::cloneMenuLinks in src/Form/EntityMenuLinkCloneForm.php
Clone menu items.
EntityMenuLinkCloneForm::menuLinksAvailabilityCheck in src/Form/EntityMenuLinkCloneForm.php
Check Menu Link items are availabe inside the menu.

File

src/Form/EntityMenuLinkCloneForm.php, line 143

Class

EntityMenuLinkCloneForm
Provides a menu link clone form.

Namespace

Drupal\menu_link_clone\Form

Code

protected function getMenuItems($menu_id) {
  $result = [];
  $storage = $this->entityTypeManager
    ->getStorage('menu_link_content');
  $menuLinkItems = $storage
    ->loadByProperties([
    'menu_name' => $menu_id,
  ]);
  if (!empty($menuLinkItems)) {
    $result['status'] = TRUE;
    $result['items'] = $menuLinkItems;
  }
  else {
    $result['status'] = FALSE;
    $result['items'] = [];
  }
  return $result;
}