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

(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?
Reply
#2

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

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

// Load Contoller
$controller = new $controller;
var_dump(controller->data);
Reply




Theme © iAndrew 2016 - Forum software by © MyBB