You are here

protected function MenuLinkContentTrait::createMenuContentLink in Menu Admin per Menu 8

Creates a menu link content based on default settings.

Parameters

array $values: An array of settings to change from the defaults. Example: 'menu_name' => 'foo'.

Return value

\Drupal\menu_link_content\MenuLinkContentInterface The created menu link.

1 call to MenuLinkContentTrait::createMenuContentLink()
MenuAdminPerMenuMenuPagesTest::testMenuLinkContentPages in tests/src/Functional/MenuAdminPerMenuMenuPagesTest.php
Test the menu_link_content pages.

File

tests/src/Traits/MenuLinkContentTrait.php, line 28

Class

MenuLinkContentTrait
Provides methods to create menu_content_links from given values.

Namespace

Drupal\Tests\menu_admin_per_menu\Traits

Code

protected function createMenuContentLink(array $values = []) : MenuLinkContentInterface {
  $menu_link = MenuLinkContent::create($values + [
    'title' => $this
      ->randomMachineName(),
    'menu_name' => 'main',
    'link' => [
      'uri' => 'route:<front>',
    ],
    'provider' => 'menu_link_content',
  ]);
  $menu_link
    ->save();
  return $menu_link;
}