Skip to content

Instantly share code, notes, and snippets.

@vijaycs85
Last active February 4, 2016 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijaycs85/0058052ed4d9d3362293 to your computer and use it in GitHub Desktop.
Save vijaycs85/0058052ed4d9d3362293 to your computer and use it in GitHub Desktop.
<?php
// Create a menu.
$values = array(
'id' => 'menu-test',
'label' => 'Test menu',
'description' => 'Description text',
);
\Drupal::entityTypeManager()->getStorage('menu')->create($values)->save();
// Create 300 menu items.
$storage = \Drupal::entityTypeManager()->getStorage('menu_link_content');
$base_options = array(
'title' => 'Menu link test',
'provider' => 'menu_link_content',
'bundle' => 'menu_link_content',
'menu_name' => 'menu-test',
);
$values = $base_options + array(
'link' => ['uri' => 'internal:/menu-test/hierarchy/parent'],
);
for ($i = 0; $i <300; $i++) {
$values['title'] = 'Menu link test' . $i;
$storage->create($values)->save();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment