class ContactPermissionsContactPageAccess in Contact Permissions 8.2
Same name and namespace in other branches
- 8 src/Access/ContactPermissionsContactPageAccess.php \Drupal\contact_permissions\Access\ContactPermissionsContactPageAccess
Access check for contact_personal_page route.
Hierarchy
- class \Drupal\contact\Access\ContactPageAccess implements AccessInterface
- class \Drupal\contact_permissions\Access\ContactPermissionsContactPageAccess
Expanded class hierarchy of ContactPermissionsContactPageAccess
1 string reference to 'ContactPermissionsContactPageAccess'
1 service uses ContactPermissionsContactPageAccess
File
- src/
Access/ ContactPermissionsContactPageAccess.php, line 13
Namespace
Drupal\contact_permissions\AccessView source
class ContactPermissionsContactPageAccess extends ContactPageAccess {
/**
* {@inheritdoc}
*/
public function access(UserInterface $user, AccountInterface $account) {
/* \Drupal\Core\Access\AccessResult $access */
$access = parent::access($user, $account);
if (!$access
->isAllowed() && $access
->getReason() == "The 'access user contact forms' permission is required.") {
foreach ($user
->getRoles() as $role_id) {
$permission_access = AccessResult::allowedIfHasPermission($account, "use {$role_id} personal contact forms");
if ($permission_access
->isAllowed()) {
$access = $permission_access;
break;
}
}
}
return $access
->andif(AccessResult::allowedIfHasPermission($user, 'have a personal contact form'));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContactPageAccess:: |
protected | property | The contact settings config object. | |
ContactPageAccess:: |
protected | property | The user data service. | |
ContactPageAccess:: |
public | function | Constructs a ContactPageAccess instance. | |
ContactPermissionsContactPageAccess:: |
public | function |
Checks access to the given user's contact page. Overrides ContactPageAccess:: |