comparison core/modules/shortcut/shortcut.api.php @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
1 <?php
2
3 /**
4 * @file
5 * Hooks provided by the Shortcut module.
6 */
7
8 /**
9 * @addtogroup hooks
10 * @{
11 */
12
13 /**
14 * Return the name of a default shortcut set for the provided user account.
15 *
16 * This hook allows modules to define default shortcut sets for a particular
17 * user that differ from the site-wide default (for example, a module may want
18 * to define default shortcuts on a per-role basis).
19 *
20 * The default shortcut set is used only when the user does not have any other
21 * shortcut set explicitly assigned to them.
22 *
23 * Note that only one default shortcut set can exist per user, so when multiple
24 * modules implement this hook, the last (i.e., highest weighted) module which
25 * returns a valid shortcut set name will prevail.
26 *
27 * @param $account
28 * The user account whose default shortcut set is being requested.
29 * @return string
30 * The name of the shortcut set that this module recommends for that user, if
31 * there is one.
32 */
33 function hook_shortcut_default_set($account) {
34 // Use a special set of default shortcuts for administrators only.
35 $roles = \Drupal::entityManager()->getStorage('user_role')->loadByProperties(['is_admin' => TRUE]);
36 $user_admin_roles = array_intersect(array_keys($roles), $account->getRoles());
37 if ($user_admin_roles) {
38 return 'admin-shortcuts';
39 }
40 }
41
42 /**
43 * @} End of "addtogroup hooks".
44 */