public function SubscriptionsAccountForm::checkAccess in Simplenews 8
Same name and namespace in other branches
- 8.2 src/Form/SubscriptionsAccountForm.php \Drupal\simplenews\Form\SubscriptionsAccountForm::checkAccess()
- 3.x src/Form/SubscriptionsAccountForm.php \Drupal\simplenews\Form\SubscriptionsAccountForm::checkAccess()
Checks access for the simplenews account form.
Parameters
\Drupal\user\UserInterface $user: The account to use in the form.
Return value
\Drupal\Core\Access\AccessResult An access result object.
1 string reference to 'SubscriptionsAccountForm::checkAccess'
File
- src/
Form/ SubscriptionsAccountForm.php, line 62
Class
- SubscriptionsAccountForm
- Configure simplenews subscriptions of a user.
Namespace
Drupal\simplenews\FormCode
public function checkAccess(UserInterface $user) {
$account = $this
->currentUser();
// Deny access for anonymous user at /user/0/simplenews.
if ($user
->isAnonymous()) {
return AccessResult::forbidden();
}
return AccessResult::allowedIfHasPermission($account, 'administer simplenews subscriptions')
->orIf(AccessResult::allowedIfHasPermission($account, 'subscribe to newsletters')
->andIf(AccessResult::allowedIf($user
->id() == $account
->id())));
}