Tobia
Tobia

Reputation: 9506

How to pass a param in Slim4 route middleware?

I'm using Slim4 and I need to pass a param in middleware route configurations.

In my example I need to define the required ROLE of user in a Authorization middleware.

I need to check that user is a manager in the first route group, and an admin in the second route group.

$app->group('',function() use ($app){        
    $app->get('/manager',ManagerAction::class.':home')->setName("manager");
})->add(UserAuthMiddleware::class);

$app->group('',function() use ($app){        
    $app->get('/admin', AdminAction::class.':home')->setName("admin");
})->add(UserAuthMiddleware::class);

Upvotes: 1

Views: 70

Answers (1)

wieczorek1990
wieczorek1990

Reputation: 8078

You should check the possiblilities of the group return value and if it only allows to take class then it is probably impossible to do what you want. Maybe take it to their GitHub.

Upvotes: 0

Related Questions