comparison core/lib/Drupal/Core/Session/AccountInterface.php @ 0:4c8ae668cc8c

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