How do we build custom global functions correctly into the PHPBB ext system? I have a custom PHP function I want available on every page, and without manually writing it into functions.php or one of the other global php files I am not sure how to achieve that. This is an entirely custom function (and I am amenable to having it injected as its own custom class of custom functions globally as well, and then sending that out as a new global variable or something) that can't conceivably hook into any existing events we have available, but it definitely needs to be globally available on every page without necessarily getting-called (at least, not immediately) on every page. I'm picturing it functioning like most of our global variables already do, where you either call them with global $var or you add them to the constructor of a class, and then call them off $this->.
I tried setting up a service and listener with the functions just kind of dumped inside the load language function there but no luck (it was a shot in the dark).
For example purposes, pretend it reads like below.
Code: Select all
public function do_this_thing_on_every_page(){
//query to insert stuff into db or some such
}
Code: Select all
if (user takes some action they could take anywhere at any time){
do_this_thing_on_every_page();
}
OR
global $newThing;
if (conditional){
$newThing->do_this_thing_on_every_page();
}