Welcome Guest, Not a member yet? Register   Sign In
Pass data to filter

(This post was last modified: 11-16-2022, 01:59 PM by motoroller.)

Hello, tell me please can i pass some data (from controller) to filter before?

For example i have some data in controller like name, type, acceess and i need it pass to filter, to undestand this user can access to page or not.
I can do it in constructor, but its not correct way, how decide this problem? or use after event?

Filter::before() are fired before the controller is initialized.
You in principle will not be able to get any data from the controller.

// Get Name of controller
$router = service('router');
$controller = $router->controllerName();

// Load Contoller
$controller = new $controller;

Theme © iAndrew 2016 - Forum software by © MyBB