From ac9742ba5c55dbe3d648d27993b2cd1371023525 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 16 Oct 2019 13:15:37 +0200 Subject: [PATCH] User: added getAuthenticatorIfExists & getAuthorizatorIfExists() --- src/Security/User.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Security/User.php b/src/Security/User.php index 780a1cb8..d6458d16 100644 --- a/src/Security/User.php +++ b/src/Security/User.php @@ -149,7 +149,7 @@ public function setAuthenticator(IAuthenticator $handler) final public function getAuthenticator(): ?IAuthenticator { if (func_num_args()) { - trigger_error(__METHOD__ . '() parameter $throw is deprecated, use hasAuthenticator()', E_USER_DEPRECATED); + trigger_error(__METHOD__ . '() parameter $throw is deprecated, use getAuthenticatorIfExists()', E_USER_DEPRECATED); $throw = func_get_arg(0); } if (($throw ?? true) && !$this->authenticator) { @@ -159,6 +159,15 @@ final public function getAuthenticator(): ?IAuthenticator } + /** + * Returns authentication handler. + */ + final public function getAuthenticatorIfExists(): ?IAuthenticator + { + return $this->authenticator; + } + + /** * Does the authentication exist? */ @@ -260,7 +269,7 @@ public function setAuthorizator(IAuthorizator $handler) final public function getAuthorizator(): ?IAuthorizator { if (func_num_args()) { - trigger_error(__METHOD__ . '() parameter $throw is deprecated, use hasAuthorizator()', E_USER_DEPRECATED); + trigger_error(__METHOD__ . '() parameter $throw is deprecated, use getAuthorizatorIfExists()', E_USER_DEPRECATED); $throw = func_get_arg(0); } if (($throw ?? true) && !$this->authorizator) { @@ -270,6 +279,15 @@ final public function getAuthorizator(): ?IAuthorizator } + /** + * Returns current authorization handler. + */ + final public function getAuthorizatorIfExists(): ?IAuthorizator + { + return $this->authorizator; + } + + /** * Does the authorization exist? */