You are here

public static function SmartIp::isUserDebugMode in Smart IP 8.3

Same name and namespace in other branches
  1. 8.4 src/SmartIp.php \Drupal\smart_ip\SmartIp::isUserDebugMode()

Check if the current user is in debug mode.

Parameters

int $uid: User ID.

Return value

bool TRUE if the current user is in debug mode and FALSE if not.

2 calls to SmartIp::isUserDebugMode()
DeviceGeolocationController::check in modules/device_geolocation/src/Controller/DeviceGeolocationController.php
Check for Geolocation attempt.
device_geolocation_page_attachments in modules/device_geolocation/device_geolocation.module
Implements hook_page_attachments().

File

src/SmartIp.php, line 198
Contains \Drupal\smart_ip\SmartIp.

Class

SmartIp
Smart IP static basic methods wrapper.

Namespace

Drupal\smart_ip

Code

public static function isUserDebugMode($uid = NULL) {
  $inDebugMode = FALSE;
  $config = \Drupal::config('smart_ip.settings');
  $user = $uid ? User::load($uid) : \Drupal::currentUser();
  $userRoles = $user
    ->getRoles();
  $rolesDebug = $config
    ->get('roles_in_debug_mode');
  foreach ($userRoles as $userRole) {
    if (isset($rolesDebug[$userRole]) && $rolesDebug[$userRole]) {
      $inDebugMode = TRUE;
      break;
    }
  }
  return $inDebugMode;
}