mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 18:04:03 +00:00
Make providing identification middleware statically to controllers work (#18)
* Test identification with universal flag with statically provided MW * Include statically provided controller MW in `tenancy()->getRouteMiddleware()` * Fix code style (php-cs-fixer) * Fix PHPStan error * Test path ID MW and route cloning with statically provided MW * Create validate.yml * set continue-on-error to true * change continue-on-error to fail-fast * add job name and use if: always() * update todo * Update path identification and Fortify integration-related logic (#13) * Add commented UrlBinding + FortifyRouteTenancy bootstrappers to the config * Improve FortifyRoute bootstrapper docblock * Rename bootstrappers * Complete renaming * Pass defaults of the original URL generator to the new one * Fix URL generator-related test (query string id test WIP) * Fix code style (php-cs-fixer) * Make Fortify bootstrapper not depend on the UrlGenerator bootstrapper, update comments * Fix testing UrlGenerator bootstrapper * Update TenancyUrlGenerator annotations * Pass tenant parameter manually in Fortify bootstrapper * Properly test TenancyUrlGenerator functionality * Get rid of query string in Fortify bootstrapper * Fix code style (php-cs-fixer) * Delete outdated comment * Improve comment * Improve before/afterEach * Encourage passing parameters using TenancyUrlGenerator instead of URL::defaults() * Delete rest of defaulting logic * Fix code style (php-cs-fixer) * Delete test group * Update ForgetTenantParameter docblock * Update passTenantParameterToRoutes annotation * Complete todo in test * Improve test * Update comment * Improve comment * Add keepQueryParameters bool to Fortify bootstrapper * Test keepQueryParameters * minor docblock update * minor docblock changes * Delete extra import * Update src/Overrides/TenancyUrlGenerator.php Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com> * Improve comment * Rename test * Update bypass parameter-related test comments * Fix merge * Rename $keepQueryParameters * Add docblock * Add comment * Refactor Fortify bootstrapper * Fix code style (php-cs-fixer) * Fix comment * Skip Fortify bootstrapper test * minor code improvements * Improve fortify bootstrapper test * Add Fortify bootstrapper annotation, improve code * Fix code style (php-cs-fixer) * Add commenet * Complete resource syncing todo (cleanup not needed) * Delete incorrect namespace * Complete route context trait name todo * Fix code style (php-cs-fixer) --------- Co-authored-by: PHP CS Fixer <phpcsfixer@example.com> Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com> * Include statically provided controller MW in `tenancy()->getRouteMiddleware()` * Fix code style (php-cs-fixer) * Improve PHPStan error fix * Include statically provided controller MW in `tenancy()->getRouteMiddleware()` * Fix PHPStan error * Fix code style (php-cs-fixer) * Include statically provided controller MW in `tenancy()->getRouteMiddleware()` * Fix code style (php-cs-fixer) --------- Co-authored-by: PHP CS Fixer <phpcsfixer@example.com> Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
This commit is contained in:
parent
4953c69fd8
commit
e4df597d81
3 changed files with 128 additions and 11 deletions
|
|
@ -7,6 +7,7 @@ namespace Stancl\Tenancy\Concerns;
|
|||
use Closure;
|
||||
use Illuminate\Contracts\Http\Kernel;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controllers\HasMiddleware;
|
||||
use Illuminate\Routing\Route;
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Support\Arr;
|
||||
|
|
@ -81,6 +82,12 @@ trait DealsWithRouteContexts
|
|||
public static function getRouteMiddleware(Route $route): array
|
||||
{
|
||||
$routeMiddleware = $route->middleware();
|
||||
$controllerClass = $route->getControllerClass();
|
||||
|
||||
if ($controllerClass && is_a($controllerClass, HasMiddleware::class, true)) {
|
||||
$routeMiddleware = array_merge($routeMiddleware, $route->controllerMiddleware());
|
||||
}
|
||||
|
||||
$middlewareGroups = RouteFacade::getMiddlewareGroups();
|
||||
$unpackGroupMiddleware = function (array $middleware) use ($middlewareGroups) {
|
||||
$innerMiddleware = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue