function MenuUiHooks::getMenuLinkContentAccess
Check if user is allowed to use the menu link subform.
Parameters
array $defaults: An array that contains default values for the menu link form.
See also
menu_ui_get_menu_link_defaults()
1 call to MenuUiHooks::getMenuLinkContentAccess()
- MenuUiHooks::formNodeFormAlter in core/
modules/ menu_ui/ src/ Hook/ MenuUiHooks.php - Implements hook_form_BASE_FORM_ID_alter() for \Drupal\node\Form\NodeForm.
File
-
core/
modules/ menu_ui/ src/ Hook/ MenuUiHooks.php, line 110
Class
- MenuUiHooks
- Hook implementations for menu_ui.
Namespace
Drupal\menu_ui\HookCode
protected function getMenuLinkContentAccess(array $defaults) : AccessResultInterface {
if (!empty($defaults['entity_id'])) {
$entity = MenuLinkContent::load($defaults['entity_id']);
// The form can be used to edit or delete the menu link.
return $entity->access('update', NULL, TRUE)
->andIf($entity->access('delete', NULL, TRUE));
}
else {
// If the node has no corresponding menu link, users needs to permission
// to create one.
return $this->entityTypeManager
->getAccessControlHandler('menu_link_content')
->createAccess(NULL, NULL, [], TRUE);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.