You are here

public function Generator::menuItem in Style Guide 8

Same name and namespace in other branches
  1. 2.x src/Generator.php \Drupal\styleguide\Generator::menuItem()

Generate a random menu item.

Parameters

string $url: The internal path or external URL being linked to.

Return value

array A random menu item, see menu_tree_page_data for a description of the data structure.

Overrides GeneratorInterface::menuItem

File

src/Generator.php, line 228

Class

Generator
Class Generator.

Namespace

Drupal\styleguide

Code

public function menuItem($url) {
  $menu_item = [
    '#type' => 'link',
    '#title' => $this
      ->sentence(),
    '#url' => Url::fromUserInput($url),
  ];
  return $menu_item;
}