function preview_link_entity_field_access in Preview Link 2.0.x
Same name and namespace in other branches
- 2.x preview_link.module \preview_link_entity_field_access()
Implements hook_entity_field_access().
File
- ./
preview_link.module, line 80 - Module file.
Code
function preview_link_entity_field_access(string $operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) : AccessResultInterface {
$storageDefinition = $field_definition
->getFieldStorageDefinition();
if ($storageDefinition
->getTargetEntityTypeId() !== 'preview_link') {
return AccessResult::neutral();
}
if ($storageDefinition
->getName() === 'entities' && $operation === 'edit') {
return AccessResult::forbiddenIf(\Drupal::configFactory()
->get('preview_link.settings')
->get('multiple_entities') !== TRUE)
->addCacheTags([
'config:preview_link.settings',
]);
}
return AccessResult::neutral();
}