Version 1
[yaffs-website] / vendor / drush / drush / lib / Drush / User / User8.php
1 <?php
2
3
4 namespace Drush\User;
5
6 use Drupal\user\Entity\User;
7
8 class User8 extends UserVersion {
9
10   /**
11    * {inheritdoc}
12    */
13   public function create($properties) {
14     $account = entity_create('user', $properties);
15     $account->save();
16     return new UserSingle8($account);
17   }
18
19   /**
20    * Attempt to load a user account.
21    *
22    * @param int $uid
23    * @return \Drupal\user\Entity\User;
24    */
25   public function load_by_uid($uid) {
26     return User::load($uid);
27   }
28
29   /**
30    * {inheritdoc}
31    */
32   public function getCurrentUserAsAccount() {
33     return \Drupal::currentUser()->getAccount();
34   }
35
36   /**
37    * Set the current user in Drupal.
38    *
39    * @param \Drupal\Core\Session\AccountInterface $account
40    */
41   public function setCurrentUser($account) {
42     // Some parts of Drupal still rely on a global user object.
43     // @todo remove once https://www.drupal.org/node/2163205 is in.
44     global $user;
45     $user = $account;
46     \Drupal::currentUser()->setAccount($account);
47   }
48 }