X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fchi-teck%2Fdrupal-code-generator%2Ftemplates%2Fd8%2Fhook%2Fentity_field_access_alter.twig;fp=vendor%2Fchi-teck%2Fdrupal-code-generator%2Ftemplates%2Fd8%2Fhook%2Fentity_field_access_alter.twig;h=7982a8241859f0a17abf316cc482a86b1756df94;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_field_access_alter.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_field_access_alter.twig new file mode 100644 index 000000000..7982a8241 --- /dev/null +++ b/vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_field_access_alter.twig @@ -0,0 +1,16 @@ +/** + * Implements hook_entity_field_access_alter(). + */ +function {{ machine_name }}_entity_field_access_alter(array &$grants, array $context) { + /** @var \Drupal\Core\Field\FieldDefinitionInterface $field_definition */ + $field_definition = $context['field_definition']; + if ($field_definition->getName() == 'field_of_interest' && $grants['node']->isForbidden()) { + // Override node module's restriction to no opinion (neither allowed nor + // forbidden). We don't want to provide our own access hook, we only want to + // take out node module's part in the access handling of this field. We also + // don't want to switch node module's grant to + // AccessResultInterface::isAllowed() , because the grants of other modules + // should still decide on their own if this field is accessible or not + $grants['node'] = AccessResult::neutral()->inheritCacheability($grants['node']); + } +}