menu_admin_per_menu.api.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * @file
  4. * Hooks provided by the Menu Admin per Menu module.
  5. */
  6. use Drupal\Core\Session\AccountInterface;
  7. /**
  8. * @addtogroup hooks
  9. * @{
  10. */
  11. /**
  12. * Alter the menus for which a user has per menu admin permissions.
  13. *
  14. * @param array $perm_menus
  15. * The $perm_menus array returned by getPerMenuPermissions()
  16. * for a user account. Values in array are menu machine names and keys are
  17. * permission name for appropriate menu.
  18. *
  19. * @param \Drupal\Core\Session\AccountInterface $account
  20. * The user account object.
  21. *
  22. * @see \Drupal\menu_admin_per_menu\MenuAdminPerMenuAccessInterface::getPerMenuPermissions()
  23. * @ingroup menu
  24. */
  25. function hook_menu_admin_per_menu_get_permissions_alter(&$perm_menus, AccountInterface $account) {
  26. // Our sample module never allows certain roles to edit or delete
  27. // content. Since some other node access modules might allow this
  28. // permission, we expressly remove it by returning an empty $grants
  29. // array for roles specified in our variable setting.
  30. if ($account->id()) {
  31. $perm_menus['administer custom-menu menu items'] = 'custom-menu';
  32. }
  33. }
  34. /**
  35. * @} End of "addtogroup hooks".
  36. */