mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 17:44:04 +00:00
Identification middleware & tests
This commit is contained in:
parent
a17727b437
commit
8ea4940f34
18 changed files with 362 additions and 174 deletions
|
|
@ -8,7 +8,7 @@ use Illuminate\Routing\Route;
|
|||
use Stancl\Tenancy\Resolvers\PathTenantResolver;
|
||||
use Stancl\Tenancy\Tenancy;
|
||||
|
||||
class InitializeTenancyByPath
|
||||
class InitializeTenancyByPath extends IdentificationMiddleware
|
||||
{
|
||||
/** @var Tenancy */
|
||||
protected $tenancy;
|
||||
|
|
@ -27,14 +27,15 @@ class InitializeTenancyByPath
|
|||
/** @var Route $route */
|
||||
$route = $request->route();
|
||||
|
||||
// todo test the behavior described by the comment
|
||||
// Only initialize tenancy if tenant is the first parameter
|
||||
// We don't want to initialize tenancy if the tenant is
|
||||
// simply injected into some route controller action.
|
||||
if ($route->parameterNames()[0] === 'tenant') {
|
||||
$this->tenancy->initialize(
|
||||
$this->resolver->resolve($route)
|
||||
return $this->initializeTenancy(
|
||||
$request, $next, $route
|
||||
);
|
||||
}
|
||||
} // todo else case should probably throw exception about malformed route? or do we just leave that as the developer's responsibility?
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue