mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 19:14:04 +00:00
[2.x] Add missing field in InitializeTenancy middleware (#135)
* Add missing field * Make field protected * Specify exact exception type * Changed Closure on callable
This commit is contained in:
parent
d00cf97e0e
commit
3f4018f93c
1 changed files with 6 additions and 2 deletions
|
|
@ -5,10 +5,14 @@ declare(strict_types=1);
|
||||||
namespace Stancl\Tenancy\Middleware;
|
namespace Stancl\Tenancy\Middleware;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
|
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedException;
|
||||||
|
|
||||||
class InitializeTenancy
|
class InitializeTenancy
|
||||||
{
|
{
|
||||||
public function __construct(Closure $onFail = null)
|
/** @var callable */
|
||||||
|
protected $onFail;
|
||||||
|
|
||||||
|
public function __construct(callable $onFail = null)
|
||||||
{
|
{
|
||||||
$this->onFail = $onFail ?? function ($e) {
|
$this->onFail = $onFail ?? function ($e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
|
|
@ -26,7 +30,7 @@ class InitializeTenancy
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
tenancy()->init();
|
tenancy()->init();
|
||||||
} catch (\Exception $e) {
|
} catch (TenantCouldNotBeIdentifiedException $e) {
|
||||||
($this->onFail)($e);
|
($this->onFail)($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue