But I can’t find anywhere to define new “filters” (or middleware) for routes… or globally.
I know kirby is a lighter CMS in comparison with the Laravel app framework thing. but it would make life easier sometime (like for the unpublished thing). and this is why I love it for building websites.
anyway, I’m sorry I’m hijacking you post. I was just thinking about this today, and your precontroller made me say it out loud.
Fatal error: Call to a member function filter() on null in C:\wamp64\www\plainkit\site\plugins\userManager\Routes\routes.php on line 7
It seems to me that the router isn’t yet defined when the plugins are called, but everything else user made that get’s run is run after the routing happens.
So unless I’m wrong, this is actually impossible to do?
You are right, the router is started after the plugins are loaded, otherwise you wouldn’t be able to define routes from plugins.
A filter is just a function that is called before the route is run, so you should be able to get a similar result by defining the code as a function in your plugin and calling that function at the start of each route action.