Drupal 8 で、uid からユーザー名を取得する方法

$uid = \Drupal::currentUser()->id() // if you wan to get a username of the current user
$account = \Drupal\user\Entity\User::load($uid); // pass your uid
$username = $account->getUsername();

広告