function FileFormatterBase::checkAccess
Same name in other branches
- 8.9.x core/modules/file/src/Plugin/Field/FieldFormatter/FileFormatterBase.php \Drupal\file\Plugin\Field\FieldFormatter\FileFormatterBase::checkAccess()
- 10 core/modules/file/src/Plugin/Field/FieldFormatter/FileFormatterBase.php \Drupal\file\Plugin\Field\FieldFormatter\FileFormatterBase::checkAccess()
- 11.x core/modules/file/src/Plugin/Field/FieldFormatter/FileFormatterBase.php \Drupal\file\Plugin\Field\FieldFormatter\FileFormatterBase::checkAccess()
Overrides EntityReferenceFormatterBase::checkAccess
1 call to FileFormatterBase::checkAccess()
- MediaThumbnailFormatter::checkAccess in core/
modules/ media/ src/ Plugin/ Field/ FieldFormatter/ MediaThumbnailFormatter.php - Checks access to the given entity.
1 method overrides FileFormatterBase::checkAccess()
- MediaThumbnailFormatter::checkAccess in core/
modules/ media/ src/ Plugin/ Field/ FieldFormatter/ MediaThumbnailFormatter.php - Checks access to the given entity.
File
-
core/
modules/ file/ src/ Plugin/ Field/ FieldFormatter/ FileFormatterBase.php, line 25
Class
- FileFormatterBase
- Base class for file formatters.
Namespace
Drupal\file\Plugin\Field\FieldFormatterCode
protected function checkAccess(EntityInterface $entity) {
// Only check access if the current file access control handler explicitly
// opts in by implementing FileAccessFormatterControlHandlerInterface.
$access_handler_class = $entity->getEntityType()
->getHandlerClass('access');
if (is_subclass_of($access_handler_class, '\\Drupal\\file\\FileAccessFormatterControlHandlerInterface')) {
return $entity->access('view', NULL, TRUE);
}
else {
return AccessResult::allowed();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.