From 4c7e6c0e063c40ebb1b52149d6e0e9dbb51774a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= <33033094+stancl@users.noreply.github.com> Date: Sun, 3 Mar 2019 17:04:17 +0100 Subject: [PATCH 1/2] Make snippet syntactically correct --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6506de85..6f2e3977 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ Open `app/Http/Kernel.php` and make the middleware top priority, so that it gets ```php protected $middlewarePriority = [ \Stancl\Tenancy\Middleware\InitializeTenancy::class, + // ... +]; ``` When a tenant route is visited, but the tenant can't be identified, an exception is thrown. If you want to change this behavior, to a redirect for example, add this to your `app/Providers/AppServiceProvider.php`'s `boot()` method. From ddc0e6fb1ee6a8bd61faca70c5561c6414995673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= <33033094+stancl@users.noreply.github.com> Date: Mon, 4 Mar 2019 22:19:38 +0100 Subject: [PATCH 2/2] Remove support for onFail without arguments to improve performance --- src/Middleware/InitializeTenancy.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Middleware/InitializeTenancy.php b/src/Middleware/InitializeTenancy.php index cd6383a5..3c37360a 100644 --- a/src/Middleware/InitializeTenancy.php +++ b/src/Middleware/InitializeTenancy.php @@ -25,13 +25,7 @@ class InitializeTenancy try { tenancy()->init(); } catch (\Exception $e) { - // Pass the exception to the onFail function if it takes any parameters. - $callback = $this->onFail; - if ((new \ReflectionFunction($callback))->getNumberOfParameters() > 0) { - $callback($e); - } else { - $callback(); - } + ($this->onFail)($e); } return $next($request);