7982a8241859f0a17abf316cc482a86b1756df94
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / entity_field_access_alter.twig
1 /**
2  * Implements hook_entity_field_access_alter().
3  */
4 function {{ machine_name }}_entity_field_access_alter(array &$grants, array $context) {
5   /** @var \Drupal\Core\Field\FieldDefinitionInterface $field_definition */
6   $field_definition = $context['field_definition'];
7   if ($field_definition->getName() == 'field_of_interest' && $grants['node']->isForbidden()) {
8     // Override node module's restriction to no opinion (neither allowed nor
9     // forbidden). We don't want to provide our own access hook, we only want to
10     // take out node module's part in the access handling of this field. We also
11     // don't want to switch node module's grant to
12     // AccessResultInterface::isAllowed() , because the grants of other modules
13     // should still decide on their own if this field is accessible or not
14     $grants['node'] = AccessResult::neutral()->inheritCacheability($grants['node']);
15   }
16 }