You are here

public function EntityLegalDocument::userHasAgreed in Entity Legal 8.2

Same name and namespace in other branches
  1. 4.0.x src/Entity/EntityLegalDocument.php \Drupal\entity_legal\Entity\EntityLegalDocument::userHasAgreed()
  2. 3.0.x src/Entity/EntityLegalDocument.php \Drupal\entity_legal\Entity\EntityLegalDocument::userHasAgreed()

Check if the given user has agreed to the current version of this document.

Parameters

\Drupal\Core\Session\AccountInterface|null $account: The Drupal user account to check. Default logged in user if not provided.

Return value

bool Whether or not the user has agreed to the current version.

Overrides EntityLegalDocumentInterface::userHasAgreed

File

src/Entity/EntityLegalDocument.php, line 240

Class

EntityLegalDocument
Defines the entity legal document entity.

Namespace

Drupal\entity_legal\Entity

Code

public function userHasAgreed(AccountInterface $account = NULL) {
  if (empty($account)) {
    $account = \Drupal::currentUser();
  }
  return count($this
    ->getAcceptances($account)) > 0;
}