public function EntityLegalDocument::userMustAgree in Entity Legal 3.0.x
Same name and namespace in other branches
- 8.2 src/Entity/EntityLegalDocument.php \Drupal\entity_legal\Entity\EntityLegalDocument::userMustAgree()
- 4.0.x src/Entity/EntityLegalDocument.php \Drupal\entity_legal\Entity\EntityLegalDocument::userMustAgree()
Checks to see if a given user can agree to this document.
Parameters
bool $new_user: Whether or not the user to check is a new user signup or not.
\Drupal\Core\Session\AccountInterface|null $account: The user account to check the access permissions of. Defaults to the current user if none is provided.
Return value
bool Can a user agree to this document.
Overrides EntityLegalDocumentInterface::userMustAgree
File
- src/
Entity/ EntityLegalDocument.php, line 226
Class
- EntityLegalDocument
- Defines the entity legal document entity.
Namespace
Drupal\entity_legal\EntityCode
public function userMustAgree($new_user = FALSE, AccountInterface $account = NULL) {
// User cannot agree unless there is a published version.
if (!$this
->getPublishedVersion()) {
return FALSE;
}
if (empty($account)) {
$account = \Drupal::currentUser();
}
if ($new_user) {
return !empty($this->require_signup);
}
else {
return !empty($this->require_existing) && $account
->hasPermission($this
->getPermissionExistingUser());
}
}