You are here

public function AgreementHandler::isAnonymousAgreement in Agreement 3.0.x

Same name and namespace in other branches
  1. 8.2 src/AgreementHandler.php \Drupal\agreement\AgreementHandler::isAnonymousAgreement()

Checks if we're processing an anonymous agreement.

Parameters

\Drupal\agreement\Entity\Agreement $agreement: The agreement to check for anonymous support.

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

Return value

bool TRUE if the user is anonymous and the current agreement applies to anonymous users. Otherwise FALSE.

Overrides AgreementHandlerInterface::isAnonymousAgreement

2 calls to AgreementHandler::isAnonymousAgreement()
AgreementHandler::agree in src/AgreementHandler.php
Accept the agreement for an user account.
AgreementHandler::hasAgreed in src/AgreementHandler.php
Check the status of an user account for a particular agreement.

File

src/AgreementHandler.php, line 130

Class

AgreementHandler
Agreement handler provides methods for looking up agreements.

Namespace

Drupal\agreement

Code

public function isAnonymousAgreement(Agreement $agreement, AccountProxyInterface $account) {
  if ($account
    ->isAnonymous() && in_array(RoleInterface::ANONYMOUS_ID, $agreement
    ->getSettings()['roles'])) {
    return TRUE;
  }
  return FALSE;
}