public function MenuBuilder::updateSubMenuItem in Context 8
Same name and namespace in other branches
- 8.4 modules/context_ui/src/MenuBuilder.php \Drupal\context_ui\MenuBuilder::updateSubMenuItem()
Updates the submenu item of the $entity item.
Parameters
\Drupal\context\Entity\Context $entity The given entity item.:
File
- modules/
context_ui/ src/ MenuBuilder.php, line 70
Class
- MenuBuilder
- Implements the MenuBuilder class, which configures and updates the submenu context items
Namespace
Drupal\context_uiCode
public function updateSubMenuItem(Context $entity) {
$result = $this->menuLinkManager
->loadLinksByRoute('entity.context.edit_form', [
'context' => $entity
->id(),
]);
if (!empty($result)) {
foreach ($result as $id => $instance) {
if (strpos($id, 'menu_link_content:') === 0) {
$instance
->updateLink([
'title' => $entity
->getLabel(),
'link' => $this
->getUriString($entity),
], TRUE);
}
}
$this->menuLinkManager
->rebuild();
}
else {
$this
->addSubMenuItem($entity);
}
}