// unsanitized version, in case other preprocess functions want to implement
// their own shortening logic or add markup. If they do so, they must ensure
// that $variables['name'] is safe for printing.
- $name = $account->getDisplayName();
+ $name = $account->getDisplayName();
$variables['name_raw'] = $account->getUsername();
- if (Unicode::strlen($name) > 20) {
+ if (mb_strlen($name) > 20) {
$name = Unicode::truncate($name, 15, FALSE, TRUE);
$variables['truncated'] = TRUE;
}
/**
* Implements hook_user_login().
*/
-function user_user_login($account) {
+function user_user_login(UserInterface $account) {
// Reset static cache of default variables in template_preprocess() to reflect
// the new user.
drupal_static_reset('template_preprocess');
/**
* Implements hook_user_logout().
*/
-function user_user_logout($account) {
+function user_user_logout(AccountInterface $account) {
// Reset static cache of default variables in template_preprocess() to reflect
// the new user.
drupal_static_reset('template_preprocess');
],
[
'absolute' => TRUE,
- 'language' => \Drupal::languageManager()->getLanguage($langcode)
+ 'language' => \Drupal::languageManager()->getLanguage($langcode),
]
);
}
return \Drupal::url('user.cancel_confirm', [
'user' => $account->id(),
'timestamp' => $timestamp,
- 'hashed_pass' => user_pass_rehash($account, $timestamp)
+ 'hashed_pass' => user_pass_rehash($account, $timestamp),
], $url_options);
}
$account = User::load($uid);
if (!$account) {
- drupal_set_message(t('The user account %id does not exist.', ['%id' => $uid]), 'error');
+ \Drupal::messenger()->addError(t('The user account %id does not exist.', ['%id' => $uid]));
\Drupal::logger('user')->error('Attempted to cancel non-existing user account: %id.', ['%id' => $uid]);
return;
}
}
$account->block();
$account->save();
- drupal_set_message(t('%name has been disabled.', ['%name' => $account->getDisplayName()]));
+ \Drupal::messenger()->addStatus(t('%name has been disabled.', ['%name' => $account->getDisplayName()]));
$logger->notice('Blocked user: %name %email.', ['%name' => $account->getAccountName(), '%email' => '<' . $account->getEmail() . '>']);
break;
_user_mail_notify('status_canceled', $account);
}
$account->delete();
- drupal_set_message(t('%name has been deleted.', ['%name' => $account->getDisplayName()]));
+ \Drupal::messenger()->addStatus(t('%name has been deleted.', ['%name' => $account->getDisplayName()]));
$logger->notice('Deleted user: %name %email.', ['%name' => $account->getAccountName(), '%email' => '<' . $account->getEmail() . '>']);
break;
}
* content language of the current request.
*
* @return array
- * An array as expected by drupal_render().
+ * An array as expected by \Drupal\Core\Render\RendererInterface::render().
*/
function user_view($account, $view_mode = 'full', $langcode = NULL) {
return entity_view($account, $view_mode, $langcode);
* content language of the current request.
*
* @return array
- * An array in the format expected by drupal_render().
+ * An array in the format expected by
+ * \Drupal\Core\Render\RendererInterface::render().
*/
function user_view_multiple($accounts, $view_mode = 'full', $langcode = NULL) {
return entity_view_multiple($accounts, $view_mode, $langcode);