class FieldAccessCheck in FileField Sources 8
Access check for file field source routes.
NOTE: AccessInterface has no methods declared, so it might be removed in the future.
Hierarchy
- class \Drupal\filefield_sources\Access\FieldAccessCheck implements AccessInterface
Expanded class hierarchy of FieldAccessCheck
1 file declares its use of FieldAccessCheck
- FieldAccessCheckTest.php in tests/
src/ Unit/ FieldAccessCheckTest.php
1 string reference to 'FieldAccessCheck'
1 service uses FieldAccessCheck
File
- src/
Access/ FieldAccessCheck.php, line 15
Namespace
Drupal\filefield_sources\AccessView source
class FieldAccessCheck implements AccessInterface {
/**
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs an EntityCreateAccessCheck object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager service.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* Checks access.
*
* @param string $entity_type
* Entity type.
* @param string $bundle_name
* Bundle name.
* @param string $field_name
* Field name.
* @param \Drupal\Core\Session\AccountInterface $account
* The currently logged in account.
*
* @return \Drupal\Core\Access\AccessResultInterface
* AccessResult object
*/
public function access(string $entity_type, string $bundle_name, string $field_name, AccountInterface $account) {
$field = $this->entityTypeManager
->getStorage('field_config')
->load($entity_type . '.' . $bundle_name . '.' . $field_name);
return $this->entityTypeManager
->getAccessControlHandler($entity_type)
->fieldAccess('edit', $field, $account, NULL, TRUE);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FieldAccessCheck:: |
protected | property | The entity type manager service. | |
FieldAccessCheck:: |
public | function | Checks access. | |
FieldAccessCheck:: |
public | function | Constructs an EntityCreateAccessCheck object. |