mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-13 19:04:03 +00:00
Give universal flag highest priority (#27)
* Give universal flag the highest priority (wip) * Stop forgetting tenant parameter when route-level path ID is used * Fix PHPStan errors * Simplify annotation * Fix comment * Correct annotations * Improve requestHasTenant comment * Make cloning logic only clone universal routes, delete the universal flag from the new (tenant) route * Delete APP_DEBUG * make if condition easier to read * Update DealsWithRouteContexts.php * Fix test * Fix code style (php-cs-fixer) * Move tests * Delete incorrectly committed file * Cloning routes update wip * Route cloning rework WIP * Add todo to clone routes * Fix code style (php-cs-fixer) * Route cloning fix WIP * Set CloneRoutesAsTenant::$tenantMiddleware to ID MW * Revert CloneRoutesAsTenant::$tenantMiddleware-related changes * Simplify requestHasTenant * Add and test 'ckone' flag * Delete setting $skippedRoutes from CloneRoutesAsTenant * Fix code style (php-cs-fixer) * make config key used for testing distinct from normal tenancy config keys * Update src/Actions/CloneRoutesAsTenant.php * Move 'path identification types' dataset to CloneActionTest --------- Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com> Co-authored-by: Samuel Štancl <samuel@archte.ch> Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
This commit is contained in:
parent
070828a81e
commit
c312156c18
10 changed files with 315 additions and 296 deletions
|
|
@ -118,10 +118,10 @@ class CloneRoutesAsTenant
|
|||
$pathIdentificationUsed = (! $routeHasNonPathIdentificationMiddleware) &&
|
||||
($routeHasPathIdentificationMiddleware || $pathIdentificationMiddlewareInGlobalStack);
|
||||
|
||||
$routeMode = tenancy()->getRouteMode($route);
|
||||
$routeIsUniversalOrTenant = $routeMode === RouteMode::TENANT || $routeMode === RouteMode::UNIVERSAL;
|
||||
|
||||
if ($pathIdentificationUsed && $routeIsUniversalOrTenant) {
|
||||
if (
|
||||
$pathIdentificationUsed &&
|
||||
(tenancy()->getRouteMode($route) === RouteMode::UNIVERSAL || tenancy()->routeHasMiddleware($route, 'clone'))
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -167,7 +167,11 @@ class CloneRoutesAsTenant
|
|||
// Add original route middleware to ensure there's no duplicate middleware
|
||||
unset($newRoute->action['middleware']);
|
||||
|
||||
$newRoute->middleware(tenancy()->getRouteMiddleware($route));
|
||||
// Exclude `universal` and `clone` middleware from the new route -- it should specifically be a tenant route
|
||||
$newRoute->middleware(array_filter(
|
||||
tenancy()->getRouteMiddleware($route),
|
||||
fn (string $middleware) => ! in_array($middleware, ['universal', 'clone'])
|
||||
));
|
||||
|
||||
if ($routeName && ! $route->named($tenantRouteNamePrefix . '*')) {
|
||||
// Clear the route name so that `name()` sets the route name instead of suffixing it
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue