You are here

public function MenuForm::menuNameExists in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/menu_ui/src/MenuForm.php \Drupal\menu_ui\MenuForm::menuNameExists()
  2. 9 core/modules/menu_ui/src/MenuForm.php \Drupal\menu_ui\MenuForm::menuNameExists()

Returns whether a menu name already exists.

Parameters

string $value: The name of the menu.

Return value

bool Returns TRUE if the menu already exists, FALSE otherwise.

File

core/modules/menu_ui/src/MenuForm.php, line 165

Class

MenuForm
Base form for menu edit forms.

Namespace

Drupal\menu_ui

Code

public function menuNameExists($value) {

  // Check first to see if a menu with this ID exists.
  if ($this->entityTypeManager
    ->getStorage('menu')
    ->getQuery()
    ->condition('id', $value)
    ->range(0, 1)
    ->count()
    ->execute()) {
    return TRUE;
  }

  // Check for a link assigned to this menu.
  return $this->menuLinkManager
    ->menuNameInUse($value);
}