class UserHelpTabAccess in Lightweight Directory Access Protocol (LDAP) 8.3
Same name and namespace in other branches
- 8.4 ldap_authentication/src/Access/UserHelpTabAccess.php \Drupal\ldap_authentication\Access\UserHelpTabAccess
Checks whether the use is allowed to see the help tab.
Hierarchy
- class \Drupal\ldap_authentication\Access\UserHelpTabAccess implements AccessInterface
Expanded class hierarchy of UserHelpTabAccess
1 string reference to 'UserHelpTabAccess'
- ldap_authentication.services.yml in ldap_authentication/
ldap_authentication.services.yml - ldap_authentication/ldap_authentication.services.yml
1 service uses UserHelpTabAccess
File
- ldap_authentication/
src/ Access/ UserHelpTabAccess.php, line 14
Namespace
Drupal\ldap_authentication\AccessView source
class UserHelpTabAccess implements AccessInterface {
private $config;
private $currentUser;
/**
* Constructor.
*/
public function __construct(ConfigFactoryInterface $config_factory, AccountInterface $current_user) {
$this->config = $config_factory
->get('ldap_authentication.settings');
$this->currentUser = $current_user;
}
/**
* Access callback for help tab.
*
* @return bool
* Whether user is allowed to see tab or not.
*/
public function accessLdapHelpTab() {
$mode = $this->config
->get('authenticationMode');
if ($mode == LdapAuthenticationConfiguration::MODE_MIXED) {
if (ldap_authentication_ldap_authenticated($this->currentUser)) {
return TRUE;
}
}
elseif ($mode == LdapAuthenticationConfiguration::MODE_EXCLUSIVE) {
if ($this->currentUser
->isAnonymous() || ldap_authentication_ldap_authenticated($this->currentUser)) {
return TRUE;
}
}
return FALSE;
}
/**
* {@inheritdoc}
*/
public function access(AccountInterface $account) {
if ($this
->accessLdapHelpTab()) {
return AccessResultAllowed::allowed();
}
else {
return AccessResultAllowed::forbidden();
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
UserHelpTabAccess:: |
private | property | ||
UserHelpTabAccess:: |
private | property | ||
UserHelpTabAccess:: |
public | function | ||
UserHelpTabAccess:: |
public | function | Access callback for help tab. | |
UserHelpTabAccess:: |
public | function | Constructor. |