FileAccessFormatterControlHandlerInterface
interface FileAccessFormatterControlHandlerInterface implements EntityAccessControlHandlerInterface (View source)
Defines an interface for file access handlers that need to run on file formatters.
\Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase, which file and image formatters extend, checks 'view' access on the referenced files before displaying them. That check would be useless and costly with Core's default access control implementation for files (\Drupal\file\FileAccessControlHandler grants access based on whether there are existing entities with granted access that reference the file). But it might be needed if a different access control handler with different logic is swapped in.
\Drupal\file\Plugin\Field\FieldFormatter\FileFormatterBase thus adjusts that behavior, and only checks access if the access control handler in use for files opts in by implementing this interface.
Methods
Checks access to an operation on a given entity or entity translation.
Checks access to create an entity.
Sets the module handler for this access control handler.
Checks access to an operation on a given entity field.
Details
bool|AccessResultInterface
access(EntityInterface $entity, string $operation, AccountInterface $account = NULL, bool $return_as_object = FALSE)
Checks access to an operation on a given entity or entity translation.
Use \Drupal\Core\Entity\EntityAccessControlHandlerInterface::createAccess() to check access to create an entity.
bool|AccessResultInterface
createAccess(string $entity_bundle = NULL, AccountInterface $account = NULL, array $context = [], bool $return_as_object = FALSE)
Checks access to create an entity.
resetCache()
Clears all cached access checks.
$this
setModuleHandler(ModuleHandlerInterface $module_handler)
Sets the module handler for this access control handler.
bool|AccessResultInterface
fieldAccess(string $operation, FieldDefinitionInterface $field_definition, AccountInterface $account = NULL, FieldItemListInterface $items = NULL, bool $return_as_object = FALSE)
Checks access to an operation on a given entity field.
This method does not determine whether access is granted to the entity itself, only the specific field. Callers are responsible for ensuring that entity access is also respected, for example by using \Drupal\Core\Entity\EntityAccessControlHandlerInterface::access().