function shortcut_set_edit_access
shortcut_set_edit_access(ShortcutSetInterface $shortcut_set = NULL)
Access callback for editing a shortcut set.
Parameters
Drupal\shortcut\ShortcutSetInterface $shortcut_set: (optional) The shortcut set to be edited. If not set, the current user's shortcut set will be used.
Return value
\Drupal\Core\Access\AccessResultInterface The access result.
File
- core/modules/shortcut/shortcut.module, line 57
- Allows users to manage customizable lists of shortcut links.
Code
function shortcut_set_edit_access(ShortcutSetInterface $shortcut_set = NULL) { $account = \Drupal::currentUser(); // Shortcut administrators can edit any set. if ($account->hasPermission('administer shortcuts')) { return AccessResult::allowed()->cachePerPermissions(); } // Sufficiently-privileged users can edit their currently displayed shortcut // set, but not other sets. They must also be able to access shortcuts. $may_edit_current_shortcut_set = $account->hasPermission('customize shortcut links') && (!isset($shortcut_set) || $shortcut_set == shortcut_current_displayed_set()) && $account->hasPermission('access shortcuts'); return AccessResult::allowedIf($may_edit_current_shortcut_set)->cachePerPermissions(); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!shortcut!shortcut.module/function/shortcut_set_edit_access/8.1.x