mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 22:14:03 +00:00
Refactor early identification (#47)
* Make universal route logic part of tbe early ID trait * Add requstHasTenant to prevent access MW, add todo@samuel * Delete PathIdentificationManager, move the used methods appropriately * Correct and refactor code related to the deleted PathIdentificationManager class * Add docblock * Fix code style (php-cs-fixer) * refactor globalStackMiddleware() * remove todos [ci skip] * refactor routeMiddleware() * revert bool assertions * revert more changes --------- Co-authored-by: PHP CS Fixer <phpcsfixer@example.com> Co-authored-by: Samuel Štancl <samuel@archte.ch>
This commit is contained in:
parent
b70cd0e531
commit
4e51cdbacb
19 changed files with 95 additions and 256 deletions
|
|
@ -7,11 +7,10 @@ namespace Stancl\Tenancy\Middleware;
|
|||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Stancl\Tenancy\Concerns\UsableWithEarlyIdentification;
|
||||
use Stancl\Tenancy\Concerns\UsableWithUniversalRoutes;
|
||||
use Stancl\Tenancy\Resolvers\DomainTenantResolver;
|
||||
use Stancl\Tenancy\Tenancy;
|
||||
|
||||
class InitializeTenancyByDomain extends IdentificationMiddleware implements UsableWithUniversalRoutes
|
||||
class InitializeTenancyByDomain extends IdentificationMiddleware
|
||||
{
|
||||
use UsableWithEarlyIdentification;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,16 +7,14 @@ namespace Stancl\Tenancy\Middleware;
|
|||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Stancl\Tenancy\Concerns\UsableWithEarlyIdentification;
|
||||
use Stancl\Tenancy\Concerns\UsableWithUniversalRoutes;
|
||||
use Stancl\Tenancy\Exceptions\RouteIsMissingTenantParameterException;
|
||||
use Stancl\Tenancy\PathIdentificationManager;
|
||||
use Stancl\Tenancy\Resolvers\PathTenantResolver;
|
||||
use Stancl\Tenancy\Tenancy;
|
||||
|
||||
/**
|
||||
* @see Stancl\Tenancy\Listeners\ForgetTenantParameter
|
||||
*/
|
||||
class InitializeTenancyByPath extends IdentificationMiddleware implements UsableWithUniversalRoutes
|
||||
class InitializeTenancyByPath extends IdentificationMiddleware
|
||||
{
|
||||
use UsableWithEarlyIdentification;
|
||||
|
||||
|
|
@ -55,6 +53,6 @@ class InitializeTenancyByPath extends IdentificationMiddleware implements Usable
|
|||
*/
|
||||
public function requestHasTenant(Request $request): bool
|
||||
{
|
||||
return tenancy()->getRoute($request)->hasParameter(PathIdentificationManager::getTenantParameterName());
|
||||
return tenancy()->getRoute($request)->hasParameter(PathTenantResolver::tenantParameterName());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,13 +7,12 @@ namespace Stancl\Tenancy\Middleware;
|
|||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Stancl\Tenancy\Concerns\UsableWithEarlyIdentification;
|
||||
use Stancl\Tenancy\Concerns\UsableWithUniversalRoutes;
|
||||
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedByRequestDataException;
|
||||
use Stancl\Tenancy\Overrides\TenancyUrlGenerator;
|
||||
use Stancl\Tenancy\Resolvers\RequestDataTenantResolver;
|
||||
use Stancl\Tenancy\Tenancy;
|
||||
|
||||
class InitializeTenancyByRequestData extends IdentificationMiddleware implements UsableWithUniversalRoutes
|
||||
class InitializeTenancyByRequestData extends IdentificationMiddleware
|
||||
{
|
||||
use UsableWithEarlyIdentification;
|
||||
|
||||
|
|
|
|||
|
|
@ -67,4 +67,10 @@ class PreventAccessFromUnwantedDomains
|
|||
{
|
||||
return in_array($request->getHost(), config('tenancy.identification.central_domains'), true);
|
||||
}
|
||||
|
||||
// todo@samuel
|
||||
public function requestHasTenant(Request $request): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue