public function Agreement::accountHasAgreementRole in Agreement 3.0.x
Same name and namespace in other branches
- 8.2 src/Entity/Agreement.php \Drupal\agreement\Entity\Agreement::accountHasAgreementRole()
Find if the agreement applies to an user account by role.
Parameters
\Drupal\Core\Session\AccountProxyInterface $account: The user account to check roles for.
Return value
bool TRUE if the user account has a role configured for this agreement.
File
- src/
Entity/ Agreement.php, line 114
Class
- Agreement
- Describes an agreement configuration.
Namespace
Drupal\agreement\EntityCode
public function accountHasAgreementRole(AccountProxyInterface $account) {
$account_roles = $account
->getRoles();
$settings = $this
->getSettings();
$roles = $settings['roles'];
$has_roles = array_intersect($roles, $account_roles);
return !empty($has_roles);
}