public function MenuBuilder::deleteSubMenuItem in Context 8.4
Same name and namespace in other branches
- 8 modules/context_ui/src/MenuBuilder.php \Drupal\context_ui\MenuBuilder::deleteSubMenuItem()
Deletes 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 95
Class
- MenuBuilder
- Implements the MenuBuilder class.
Namespace
Drupal\context_uiCode
public function deleteSubMenuItem(Context $entity) {
$result = $this->menuLinkManager
->loadLinksByRoute('entity.context.edit_form', [
'context' => $entity
->id(),
]);
if (!empty($result)) {
foreach ($result as $id => $instance) {
if ($instance
->isDeletable() && strpos($id, 'menu_link_content:') === 0) {
$instance
->deleteLink();
$this->menuLinkManager
->rebuild();
}
}
}
$this->menuLinkManager
->rebuild();
}