function RoleExpireApiService::processDefaultRoleDurationForUser in Role Expire 8
Same name and namespace in other branches
- 2.x src/RoleExpireApiService.php \Drupal\role_expire\RoleExpireApiService::processDefaultRoleDurationForUser()
Sets the default role duration for the current user/role combination.
It won't override the current expiration time for user's role.
Parameters
string $role_id: The ID of the role.
int $uid: The user ID.
File
- src/
RoleExpireApiService.php, line 327
Class
- RoleExpireApiService
- Class RoleExpireApiService.
Namespace
Drupal\role_expireCode
function processDefaultRoleDurationForUser($role_id, $uid) {
// Does a default expiry exist for this role?
$default_duration = $this
->getDefaultDuration($role_id);
if ($default_duration) {
$user_role_expiry = $this
->getUserRoleExpiryTime($uid, $role_id);
// If the expiry is empty then we act!.
if (!$user_role_expiry) {
// Use strtotime of default duration.
$this
->writeRecord($uid, $role_id, strtotime($default_duration));
\Drupal::logger('role_expire')
->notice(t('Added default duration @default_duration to role @role to user @account.', array(
'@default_duration' => $default_duration,
'@role' => $role_id,
'@account' => $uid,
)));
}
}
}