UserInterface.php

Contains \Drupal\user\UserInterface.

Namespace

Drupal\user

File

drupal/core/modules/user/lib/Drupal/user/UserInterface.php
View source
<?php

/**
 * @file
 * Contains \Drupal\user\UserInterface.
 */
namespace Drupal\user;

use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;

/**
 * Provides an interface defining a user entity.
 */
interface UserInterface extends EntityInterface, AccountInterface {

  /**
   * Returns a list of roles.
   *
   * @return array
   *   List of role IDs.
   */
  public function getRoles();

  /**
   * Whether a user has a certain role.
   *
   * @param string $rid
   *   The role ID to check.
   *
   * @return bool
   *   Returns TRUE if the user has the role, otherwise FALSE.
   */
  public function hasRole($rid);

  /**
   * Add a role to a user.
   *
   * @param string $rid
   *   The role ID to add.
   */
  public function addRole($rid);

  /**
   * Remove a role from a user.
   *
   * @param string $rid
   *   The role ID to remove.
   */
  public function removeRole($rid);

}

Interfaces

Namesort descending Description
UserInterface Provides an interface defining a user entity.