class FilebrowserAccessCheck in Filebrowser 8.2
Same name and namespace in other branches
- 3.x src/Access/FilebrowserAccessCheck.php \Drupal\filebrowser\Access\FilebrowserAccessCheck
Checks access to filebrowser page.
Hierarchy
- class \Drupal\filebrowser\Access\FilebrowserAccessCheck implements AccessInterface
Expanded class hierarchy of FilebrowserAccessCheck
1 string reference to 'FilebrowserAccessCheck'
1 service uses FilebrowserAccessCheck
File
- src/
Access/ FilebrowserAccessCheck.php, line 14
Namespace
Drupal\filebrowser\AccessView source
class FilebrowserAccessCheck implements AccessInterface {
/**
* A custom access check.
*
* @param \Drupal\Core\Session\AccountInterface $account
* Run access checks for this account.
* @param RouteMatchInterface $route_match
* @return AccessResult
*/
public function access(RouteMatchInterface $route_match, AccountInterface $account) {
if ($op = $route_match
->getParameter('op')) {
if ($permission = static::mapActionToPermission($op)) {
return AccessResult::allowedIfHasPermission($account, $permission);
}
}
return AccessResult::neutral();
}
protected static function mapActionToPermission($action) {
$permissions = [
'delete' => Common::DELETE_FILES,
'description' => Common::RENAME_FILES,
'folder' => Common::CREATE_FOLDER,
'upload' => Common::FILE_UPLOAD,
'rename' => Common::RENAME_FILES,
'archive' => Common::DOWNLOAD_ARCHIVE,
];
return isset($permissions[$action]) ? $permissions[$action] : NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FilebrowserAccessCheck:: |
public | function | A custom access check. | |
FilebrowserAccessCheck:: |
protected static | function |