Skip to content

Commit

Permalink
User: added getAuthenticatorIfExists & getAuthorizatorIfExists()
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Oct 16, 2019
1 parent 9aea7a8 commit ac9742b
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/Security/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -159,6 +159,15 @@ final public function getAuthenticator(): ?IAuthenticator
}


/**
* Returns authentication handler.
*/
final public function getAuthenticatorIfExists(): ?IAuthenticator
{
return $this->authenticator;
}


/**
* Does the authentication exist?
*/
Expand Down Expand Up @@ -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) {
Expand All @@ -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?
*/
Expand Down

0 comments on commit ac9742b

Please sign in to comment.