class UserHelpTabAccess in Lightweight Directory Access Protocol (LDAP) 8.4
Same name and namespace in other branches
- 8.3 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 16
Namespace
Drupal\ldap_authentication\AccessView source
class UserHelpTabAccess implements AccessInterface {
/**
* Config.
*
* @var \Drupal\Core\Config\ImmutableConfig
*/
protected $config;
/**
* Current user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $currentUser;
/**
* Externalauth.
*
* @var \Drupal\externalauth\Authmap
*/
protected $externalAuth;
/**
* Constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* Config Factory.
* @param \Drupal\Core\Session\AccountInterface $current_user
* Current user.
* @param \Drupal\externalauth\Authmap $external_auth
* External auth.
*/
public function __construct(ConfigFactoryInterface $config_factory, AccountInterface $current_user, Authmap $external_auth) {
$this->config = $config_factory
->get('ldap_authentication.settings');
$this->currentUser = $current_user;
$this->externalAuth = $external_auth;
}
/**
* Access callback for help tab.
*
* @return bool
* Whether user is allowed to see tab or not.
*/
public function accessLdapHelpTab() : bool {
$mode = $this->config
->get('authenticationMode');
if ($mode === 'mixed') {
if ($this->externalAuth
->get($this->currentUser
->id(), 'ldap_user')) {
return TRUE;
}
}
else {
if ($this->currentUser
->isAnonymous() || $this->externalAuth
->get($this->currentUser
->id(), 'ldap_user')) {
return TRUE;
}
}
return FALSE;
}
/**
* {@inheritdoc}
*/
public function access(AccountInterface $account) {
if ($this
->accessLdapHelpTab()) {
return AccessResultAllowed::allowed();
}
return AccessResultAllowed::forbidden();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
UserHelpTabAccess:: |
protected | property | Config. | |
UserHelpTabAccess:: |
protected | property | Current user. | |
UserHelpTabAccess:: |
protected | property | Externalauth. | |
UserHelpTabAccess:: |
public | function | ||
UserHelpTabAccess:: |
public | function | Access callback for help tab. | |
UserHelpTabAccess:: |
public | function | Constructor. |