- 🇫🇷France tostinni
Duplicate of 🐛 Site crashes after uninstalling module Active
Hi there!
Can someone please show me how to programmatically create menu items, that are already `tokenized`.
Here is a small code snippet of what I got, there is definitely something missing.
use Drupal\menu_link_content\Entity\MenuLinkContent;
/**
* Implements hook_install().
*/
function homepages_install() {
$items = array(
'articles' => 'Articles',
'brands' => 'Brands',
'products' => 'Products'
);
foreach($items as $path => $title) {
$menu_link = MenuLinkContent::create([
'title' => $title,
'link' => [
'uri' => 'internal:/[current-page:url:relative]/' . $path,
'attributes' => ['options' => ['id' => $path]],
],
'menu_name' => 'category-menu',
'menu_token_enabled' => TRUE,
'rediscover' => FALSE,
]);
$menu_link->save();
}
}
Closed: duplicate
9.1
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Duplicate of 🐛 Site crashes after uninstalling module Active