You are here

public function AgreementHandler::canAgree in Agreement 8.2

Same name and namespace in other branches
  1. 3.0.x src/AgreementHandler.php \Drupal\agreement\AgreementHandler::canAgree()

Check if an user can bypass the agreement or if the agreement applies.

Parameters

\Drupal\agreement\Entity\Agreement $agreement: The agreement to check roles.

\Drupal\Core\Session\AccountProxyInterface $account: The user account to check bypass permission.

Overrides AgreementHandlerInterface::canAgree

File

src/AgreementHandler.php, line 122

Class

AgreementHandler
Agreement handler provides methods for looking up agreements.

Namespace

Drupal\agreement

Code

public function canAgree(Agreement $agreement, AccountProxyInterface $account) {
  return !$account
    ->hasPermission('bypass agreement') && $agreement
    ->accountHasAgreementRole($account);
}