Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / node_grants_alter.twig
1 /**
2  * Implements hook_node_grants_alter().
3  */
4 function {{ machine_name }}_node_grants_alter(&$grants, $account, $op) {
5   // Our sample module never allows certain roles to edit or delete
6   // content. Since some other node access modules might allow this
7   // permission, we expressly remove it by returning an empty $grants
8   // array for roles specified in our variable setting.
9
10   // Get our list of banned roles.
11   $restricted = variable_get('example_restricted_roles', array());
12
13   if ($op != 'view' && !empty($restricted)) {
14     // Now check the roles for this account against the restrictions.
15     foreach ($restricted as $role_id) {
16       if (isset($account->roles[$role_id])) {
17         $grants = array();
18       }
19     }
20   }
21 }