You are here

protected function OgMenuTrait::createOgMenuItem in Organic Groups Menu (OG Menu) 8

Creates a menu link.

Used to create menu links for og menu instances. The $item data is an array ready to be passed to the MenuLinkContent::create method.

@code

$item_data = [ 'title' => 'My label for the menu', 'link' => [ 'uri' => '/path/of/menu/item', ], 'menu_name' => menu_machine_name, 'weight' => 1, 'expanded' => TRUE, ];

@end_code

Parameters

array $item_data: The item data.

See also

\Drupal\menu_link_content\Entity\MenuLinkContent::create()

File

src/Tests/Traits/OgMenuTrait.php, line 92

Class

OgMenuTrait
Helper methods to use in OG Menu tests.

Namespace

Drupal\og_menu\Tests\Traits

Code

protected function createOgMenuItem(array $item_data) {
  $menu_link = MenuLinkContent::create($item_data);
  $menu_link
    ->save();
}