You are here

protected function BigMenuUiTest::createMenuLink in Big Menu 2.x

Create a menu link.

Parameters

string $title: The title.

string $uri: The uri.

string|null $parent: The parent.

bool $enabled: If the link is enabled.

Return value

\Drupal\menu_link_content\MenuLinkContentInterface The menu link.

2 calls to BigMenuUiTest::createMenuLink()
BigMenuUiTest::testBigMenuUi in tests/src/Functional/BigMenuUiTest.php
Tests the Big Menu interface.
BigMenuUiTest::testBigMenuUiDeleteMenuLink in tests/src/Functional/BigMenuUiTest.php
Tests for deleting a menu link when viewing children.

File

tests/src/Functional/BigMenuUiTest.php, line 156

Class

BigMenuUiTest
Tests the Big Menu interface.

Namespace

Drupal\Tests\bigmenu\Functional

Code

protected function createMenuLink($title, $uri = 'internal:/', $parent = NULL, $enabled = TRUE) : MenuLinkContentInterface {
  $values = [
    'title' => $title,
    'link' => [
      [
        'uri' => $uri,
      ],
    ],
    'menu_name' => $this->menu
      ->id(),
    'enabled' => $enabled,
  ];
  if ($parent) {
    $values['parent'] = 'menu_link_content:' . $parent;
  }
  $link = MenuLinkContent::create($values);
  $link
    ->save();
  return $link;
}