You are here

public function AutologoutManager::logoutRole in Automated Logout 8

Helper to determine if a given user should be autologged out.

Parameters

\Drupal\user\UserInterface $user: User entity.

Return value

bool TRUE if the user should be autologged out, otherwise FALSE.

Overrides AutologoutManagerInterface::logoutRole

File

src/AutologoutManager.php, line 362

Class

AutologoutManager
Defines an AutologoutManager service.

Namespace

Drupal\autologout

Code

public function logoutRole(UserInterface $user) {
  if ($this->autoLogoutSettings
    ->get('role_logout')) {
    foreach ($user->roles as $name => $role) {
      if ($this->configFactory
        ->get('autologout.role.' . $name . '.enabled')) {
        return TRUE;
      }
    }
  }
  return FALSE;
}