public function MenuBuilder::addSubMenuItem in Context 8.4
Same name and namespace in other branches
- 8 modules/context_ui/src/MenuBuilder.php \Drupal\context_ui\MenuBuilder::addSubMenuItem()
Adds a submenu item for the $entity item.
Parameters
\Drupal\context\Entity\Context $entity: The given entity item.
1 call to MenuBuilder::addSubMenuItem()
- MenuBuilder::updateSubMenuItem in modules/
context_ui/ src/ MenuBuilder.php - Updates the submenu item of the $entity item.
File
- modules/
context_ui/ src/ MenuBuilder.php, line 51
Class
- MenuBuilder
- Implements the MenuBuilder class.
Namespace
Drupal\context_uiCode
public function addSubMenuItem(Context $entity) {
$menu_link = MenuLinkContent::create([
'title' => $entity
->getLabel(),
'link' => $this
->getUriString($entity),
'menu_name' => 'admin',
'parent' => 'entity.context.collection',
'expanded' => TRUE,
'weight' => 10,
]);
$menu_link
->save();
$this->menuLinkManager
->rebuild();
}