Skip to content

Commit

Permalink
Added AbstractConnection::callWithDisabledAuth()
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Mar 31, 2017
1 parent b84723b commit 122a889
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/AbstractConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,26 @@ public function setDisabledAuth($disabledAuth)
$this->_disabledAuth = $disabledAuth;
}

/**
* Disables auth and calls $closure
*
* @param Closure $closure
* @return mixed
*/
public function callWithDisabledAuth(Closure $closure)
{
if ($this->isDisabledAuth()) {
return call_user_func($closure);
}

try {
$this->disableAuth();
return call_user_func($closure);
} finally {
$this->enableAuth();
}
}

/**
* Try to decode error information if it is valid json, return it if not.
* @param $body
Expand Down

0 comments on commit 122a889

Please sign in to comment.