- Unauthorize response now allows ResponseInterface as type

This commit is contained in:
Dave Mc Nicoll 2025-04-01 19:16:30 +00:00
parent 63c7dc23f9
commit e20157a162

View File

@ -14,11 +14,11 @@ class SecurityHandler {
protected ResponseInterface $redirectResponse;
protected ? \Closure $unauthorizeResponse;
protected \Closure|ResponseInterface|null $unauthorizeResponse;
protected ? Taxus $taxus;
public function __construct(ResponseInterface $redirectResponse, ? \Closure $unauthorizeResponse = null, ? Taxus $taxus = null) {
public function __construct(ResponseInterface $redirectResponse, \Closure|ResponseInterface|null $unauthorizeResponse = null, ? Taxus $taxus = null) {
$this->redirectResponse = $redirectResponse;
$this->unauthorizeResponse = $unauthorizeResponse;
$this->taxus = $taxus;
@ -51,6 +51,10 @@ class SecurityHandler {
}
if ($this->unauthorizeResponse) {
if ($this->unauthorizeResponse instanceof ResponseInterface) {
return $this->unauthorizeResponse;
}
return call_user_func_array($this->unauthorizeResponse, [ $user, ['method' => $fromMethod, 'object' => $fromObject ], $className, $methodName ]);
}
else {