Last active
July 24, 2017 21:08
-
-
Save ericjgruber/c57b8315f5ed58a8957ed303509b75b0 to your computer and use it in GitHub Desktop.
Get a UUID in Drupal 8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @var \Drupal\user\Entity\User $user */ | |
$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id()); | |
$uuid = $user->uuid(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To reveal the uuid in a JavaScript object, add this to the .theme file in the HOOK_preprocess_page(&$variables) function:
$variables['#attached']['drupalSettings']['uuid'] = $uuid;