• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get controller's method variables in Filter's before method

#1
Hi,

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!
Reply

#2
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" } 
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.