1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-13 01:14:04 +00:00
tenancy/src/Middleware/InitializeTenancy.php
Samuel Štancl 2fd3662eb7
[1.8.0] Use strict types (#115)
* Use strict types

* Apply fixes from StyleCI

* Fix str_repeat

* Fix false json decode
2019-08-23 18:18:26 +02:00

35 lines
645 B
PHP

<?php
declare(strict_types=1);
namespace Stancl\Tenancy\Middleware;
use Closure;
class InitializeTenancy
{
public function __construct(Closure $onFail = null)
{
$this->onFail = $onFail ?? function ($e) {
throw $e;
};
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
try {
tenancy()->init();
} catch (\Exception $e) {
($this->onFail)($e);
}
return $next($request);
}
}