Skip to content

Commit ac9742b

Browse files
committed
User: added getAuthenticatorIfExists & getAuthorizatorIfExists()
1 parent 9aea7a8 commit ac9742b

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/Security/User.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function setAuthenticator(IAuthenticator $handler)
149149
final public function getAuthenticator(): ?IAuthenticator
150150
{
151151
if (func_num_args()) {
152-
trigger_error(__METHOD__ . '() parameter $throw is deprecated, use hasAuthenticator()', E_USER_DEPRECATED);
152+
trigger_error(__METHOD__ . '() parameter $throw is deprecated, use getAuthenticatorIfExists()', E_USER_DEPRECATED);
153153
$throw = func_get_arg(0);
154154
}
155155
if (($throw ?? true) && !$this->authenticator) {
@@ -159,6 +159,15 @@ final public function getAuthenticator(): ?IAuthenticator
159159
}
160160

161161

162+
/**
163+
* Returns authentication handler.
164+
*/
165+
final public function getAuthenticatorIfExists(): ?IAuthenticator
166+
{
167+
return $this->authenticator;
168+
}
169+
170+
162171
/**
163172
* Does the authentication exist?
164173
*/
@@ -260,7 +269,7 @@ public function setAuthorizator(IAuthorizator $handler)
260269
final public function getAuthorizator(): ?IAuthorizator
261270
{
262271
if (func_num_args()) {
263-
trigger_error(__METHOD__ . '() parameter $throw is deprecated, use hasAuthorizator()', E_USER_DEPRECATED);
272+
trigger_error(__METHOD__ . '() parameter $throw is deprecated, use getAuthorizatorIfExists()', E_USER_DEPRECATED);
264273
$throw = func_get_arg(0);
265274
}
266275
if (($throw ?? true) && !$this->authorizator) {
@@ -270,6 +279,15 @@ final public function getAuthorizator(): ?IAuthorizator
270279
}
271280

272281

282+
/**
283+
* Returns current authorization handler.
284+
*/
285+
final public function getAuthorizatorIfExists(): ?IAuthorizator
286+
{
287+
return $this->authorizator;
288+
}
289+
290+
273291
/**
274292
* Does the authorization exist?
275293
*/

0 commit comments

Comments
 (0)