annotate core/lib/Drupal/Core/Session/AccountInterface.php @ 13:5fb285c0d0e3

Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've been lucky to get away with this so far, as we don't support self-registration which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5 was vulnerable to.
author Chris Cannam
date Mon, 23 Apr 2018 09:33:26 +0100
parents 4c8ae668cc8c
children 1fec387a4317
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\Core\Session;
Chris@0 4
Chris@0 5 /**
Chris@0 6 * Defines an account interface which represents the current user.
Chris@0 7 *
Chris@0 8 * Defines an object that has a user id, roles and can have session data. The
Chris@0 9 * interface is implemented both by the global session and the user entity.
Chris@0 10 *
Chris@0 11 * @ingroup user_api
Chris@0 12 */
Chris@0 13 interface AccountInterface {
Chris@0 14
Chris@0 15 /**
Chris@0 16 * Role ID for anonymous users.
Chris@0 17 */
Chris@0 18 const ANONYMOUS_ROLE = 'anonymous';
Chris@0 19
Chris@0 20 /**
Chris@0 21 * Role ID for authenticated users.
Chris@0 22 */
Chris@0 23 const AUTHENTICATED_ROLE = 'authenticated';
Chris@0 24
Chris@0 25 /**
Chris@0 26 * Returns the user ID or 0 for anonymous.
Chris@0 27 *
Chris@0 28 * @return int
Chris@0 29 * The user ID.
Chris@0 30 */
Chris@0 31 public function id();
Chris@0 32
Chris@0 33 /**
Chris@0 34 * Returns a list of roles.
Chris@0 35 *
Chris@0 36 * @param bool $exclude_locked_roles
Chris@0 37 * (optional) If TRUE, locked roles (anonymous/authenticated) are not returned.
Chris@0 38 *
Chris@0 39 * @return array
Chris@0 40 * List of role IDs.
Chris@0 41 */
Chris@0 42 public function getRoles($exclude_locked_roles = FALSE);
Chris@0 43
Chris@0 44 /**
Chris@0 45 * Checks whether a user has a certain permission.
Chris@0 46 *
Chris@0 47 * @param string $permission
Chris@0 48 * The permission string to check.
Chris@0 49 *
Chris@0 50 * @return bool
Chris@0 51 * TRUE if the user has the permission, FALSE otherwise.
Chris@0 52 */
Chris@0 53 public function hasPermission($permission);
Chris@0 54
Chris@0 55 /**
Chris@0 56 * Returns TRUE if the account is authenticated.
Chris@0 57 *
Chris@0 58 * @return bool
Chris@0 59 * TRUE if the account is authenticated.
Chris@0 60 */
Chris@0 61 public function isAuthenticated();
Chris@0 62
Chris@0 63 /**
Chris@0 64 * Returns TRUE if the account is anonymous.
Chris@0 65 *
Chris@0 66 * @return bool
Chris@0 67 * TRUE if the account is anonymous.
Chris@0 68 */
Chris@0 69 public function isAnonymous();
Chris@0 70
Chris@0 71 /**
Chris@0 72 * Returns the preferred language code of the account.
Chris@0 73 *
Chris@0 74 * @param bool $fallback_to_default
Chris@0 75 * (optional) Whether the return value will fall back to the site default
Chris@0 76 * language if the user has no language preference.
Chris@0 77 *
Chris@0 78 * @return string
Chris@0 79 * The language code that is preferred by the account. If the preferred
Chris@0 80 * language is not set or is a language not configured anymore on the site,
Chris@0 81 * the site default is returned or an empty string is returned (if
Chris@0 82 * $fallback_to_default is FALSE).
Chris@0 83 */
Chris@0 84 public function getPreferredLangcode($fallback_to_default = TRUE);
Chris@0 85
Chris@0 86 /**
Chris@0 87 * Returns the preferred administrative language code of the account.
Chris@0 88 *
Chris@0 89 * Defines which language is used on administrative pages.
Chris@0 90 *
Chris@0 91 * @param bool $fallback_to_default
Chris@0 92 * (optional) Whether the return value will fall back to the site default
Chris@0 93 * language if the user has no administration language preference.
Chris@0 94 *
Chris@0 95 * @return string
Chris@0 96 * The language code that is preferred by the account for administration
Chris@0 97 * pages. If the preferred language is not set or is a language not
Chris@0 98 * configured anymore on the site, the site default is returned or an empty
Chris@0 99 * string is returned (if $fallback_to_default is FALSE).
Chris@0 100 */
Chris@0 101 public function getPreferredAdminLangcode($fallback_to_default = TRUE);
Chris@0 102
Chris@0 103 /**
Chris@0 104 * Returns the unaltered login name of this account.
Chris@0 105 *
Chris@0 106 * @return string
Chris@0 107 * An unsanitized plain-text string with the name of this account that is
Chris@0 108 * used to log in. Only display this name to admins and to the user who owns
Chris@0 109 * this account, and only in the context of the name used to log in. For
Chris@0 110 * any other display purposes, use
Chris@0 111 * \Drupal\Core\Session\AccountInterface::getDisplayName() instead.
Chris@0 112 *
Chris@0 113 * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
Chris@0 114 * Use \Drupal\Core\Session\AccountInterface::getAccountName() or
Chris@0 115 * \Drupal\user\UserInterface::getDisplayName() instead.
Chris@0 116 */
Chris@0 117 public function getUsername();
Chris@0 118
Chris@0 119 /**
Chris@0 120 * Returns the unaltered login name of this account.
Chris@0 121 *
Chris@0 122 * @return string
Chris@0 123 * An unsanitized plain-text string with the name of this account that is
Chris@0 124 * used to log in. Only display this name to admins and to the user who owns
Chris@0 125 * this account, and only in the context of the name used to login. For
Chris@0 126 * any other display purposes, use
Chris@0 127 * \Drupal\Core\Session\AccountInterface::getDisplayName() instead.
Chris@0 128 */
Chris@0 129 public function getAccountName();
Chris@0 130
Chris@0 131 /**
Chris@0 132 * Returns the display name of this account.
Chris@0 133 *
Chris@0 134 * By default, the passed-in object's 'name' property is used if it exists, or
Chris@0 135 * else, the site-defined value for the 'anonymous' variable. However, a
Chris@0 136 * module may override this by implementing
Chris@0 137 * hook_user_format_name_alter(&$name, $account).
Chris@0 138 *
Chris@0 139 * @see hook_user_format_name_alter()
Chris@0 140 *
Chris@0 141 * @return string|\Drupal\Component\Render\MarkupInterface
Chris@0 142 * Either a string that will be auto-escaped on output or a
Chris@0 143 * MarkupInterface object that is already HTML escaped. Either is safe
Chris@0 144 * to be printed within HTML fragments.
Chris@0 145 */
Chris@0 146 public function getDisplayName();
Chris@0 147
Chris@0 148 /**
Chris@0 149 * Returns the email address of this account.
Chris@0 150 *
Chris@0 151 * @return string
Chris@0 152 * The email address.
Chris@0 153 */
Chris@0 154 public function getEmail();
Chris@0 155
Chris@0 156 /**
Chris@0 157 * Returns the timezone of this account.
Chris@0 158 *
Chris@0 159 * @return string
Chris@0 160 * Name of the timezone.
Chris@0 161 */
Chris@0 162 public function getTimeZone();
Chris@0 163
Chris@0 164 /**
Chris@0 165 * The timestamp when the account last accessed the site.
Chris@0 166 *
Chris@0 167 * A value of 0 means the user has never accessed the site.
Chris@0 168 *
Chris@0 169 * @return int
Chris@0 170 * Timestamp of the last access.
Chris@0 171 */
Chris@0 172 public function getLastAccessedTime();
Chris@0 173
Chris@0 174 }