You are here

public function RoleExpireApiService::getAllUserRecords in Role Expire 8

Same name and namespace in other branches
  1. 2.x src/RoleExpireApiService.php \Drupal\role_expire\RoleExpireApiService::getAllUserRecords()

Get expiration of all roles of a user.

Parameters

int $uid: User ID.

Return value

array Array with the expiration time.

File

src/RoleExpireApiService.php, line 85

Class

RoleExpireApiService
Class RoleExpireApiService.

Namespace

Drupal\role_expire

Code

public function getAllUserRecords($uid) {
  $query = $this->database
    ->select('role_expire', 'n');
  $query
    ->fields('n', [
    'rid',
    'expiry_timestamp',
  ]);
  $query
    ->condition('n.uid', $uid, '=');
  $result = $query
    ->execute()
    ->fetchAll();
  $return = [];
  foreach ($result as $row) {
    $return[$row->rid] = $row->expiry_timestamp;
  }
  return $return;
}