Welcome Guest, Not a member yet? Register   Sign In
Get controller's method variables in Filter's before method

(This post was last modified: 07-30-2020, 04:50 AM by yassine.)


I know it is possible to get the variables in the controller's _remap() method though I'd like to have a filter handling a logic at a higher level (if possible).

Here's an example of my code:
PHP Code:
        $routes->get('users/(:num)''User::view/$1', [
            'as' => 'user',
            'filter' => 'permission:user-view',

Is there a way to get the userId I'm passing in the route inside the before method of the permission filter?

Thanks for any help!

(This post was last modified: 07-30-2020, 06:45 AM by yassine.)

Actually, nevermind, I just found out how to get the params! Smile

For anyone interested, I called the router service, in which there is the params() method.

Like so:

PHP Code:
        $router Services::router();
        echo var_dump($router->params());
// array(1) { [0]=> string(1) "1" } 

Theme © iAndrew 2016 - Forum software by © MyBB