class User8

  1. 8.0.x lib/Drush/User/User8.php User8
  2. 7.x lib/Drush/User/User8.php User8
  3. master lib/Drush/User/User8.php User8

Namespace

Drush\User

Hierarchy

Expanded class hierarchy of User8

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
User8::create public function {inheritdoc} Overrides UserVersion::create
User8::getCurrentUserAsAccount public function {inheritdoc} Overrides UserVersion::getCurrentUserAsAccount
User8::load_by_uid public function Attempt to load a user account. Overrides UserVersion::load_by_uid
User8::setCurrentUser public function Set the current user in Drupal. Overrides UserVersion::setCurrentUser
UserVersion::getCurrentUserAsSingle public function Load the current user account and return a UserSingle instance.
UserVersion::load_by_mail public function Attempt to load a user account.
UserVersion::load_by_name public function Attempt to load a user account.

File

lib/Drush/User/User8.php, line 8

View source
class User8 extends UserVersion {

  /**
   * {inheritdoc}
   */
  public function create($properties) {
    $account = entity_create('user', $properties);
    $account->save();
    return new UserSingle8($account);
  }

  /**
   * Attempt to load a user account.
   *
   * @param int $uid
   * @return \Drupal\user\Entity\User;
   */
  public function load_by_uid($uid) {
    return User::load($uid);
  }

  /**
   * {inheritdoc}
   */
  public function getCurrentUserAsAccount() {
    return \Drupal::currentUser()->getAccount();
  }

  /**
   * Set the current user in Drupal.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   */
  public function setCurrentUser($account) {
    // Some parts of Drupal still rely on a global user object.
    // @todo remove once https://www.drupal.org/node/2163205 is in.
    global $user;
    $user = $account;
    \Drupal::currentUser()->setAccount($account);
  }
}