These requests for events in core phpBB have been merged into 3.1/Ascraeus and will be available with the next release.
After the reply of PayBas, which is correct, I updated my previous post in this topic. Not sure what changing the $template means.
Hmm, couldn't you pass the $template variable to your template event handler? ...assuming you use $template as a service so there is no need for globals.
Also, we don't want to render a template in our extension, we want to use the existing template event.
Didn't see your reply.
$template is the template object that renders the template and to which variables/data is assigned. We just need a way to set our own variables to the template, relying on the service injecting the template also isn't ideal, because then the $template gets injected to the constructor every single time, regardless of whether or not our event fires. This event is only on the posting page, so why inject the template any other time? That just confuses things, especially since there are other core template modification events that do exactly what is advertised, so why is this one so different?
By "template event" we mean an <!-- EVENT --> being called in the template that simply includes another piece of HTML/template, not a PHP event.
Can you give a concrete example please?
And for the rest, i don't understand what is the problem if you get a dependence that you don't always use?
I think that the events should give only the "special" vars and not any unique public service that everyone can retrieve through the DI.
rfdy wrote: We don't want to change the $template itself. We just want to assign more variables to it, so that our template event handler has access to them. Isn't that the point of the event, to modify the assigned variables before they get assigned?
You make it sound like a contradiction, but we are basically saying the same thing .
Sorry to drag on this conversation, but the point is that the changes made by adding those additional variables to the event really doesn't help anybody if the one variable they need access to needs to be passed into the constructor. Events should be constructed in a way such that you're given all the local details you need at that moment, not rely on some global functionality (the $template service is just a fancy word for a global variable). All the other core events with "modify" in their name allow you to modify the data directly without additional constructor dependencies, however in this case the variables that are being sent with the event don't affect the template at all, hence the confusion with the name of the event. It's good that you're breaking the event vars, but changing those variables doesn't affect the template, because they're already assigned (unless they're assigned by reference, which just adds more confusion and isn't a desirable effect).
For now I will add the template to the constructor, even though my eight other events in that class don't need it and clutters up the code with additional dependencies making it harder to test.
I reread all your posts, but I think we still need a concrete example of what you are trying to do (the actual use-case). I just can't get a clear idea of what your perceived problem is.
It's late, so please excuse me if I'm ignorant or misunderstood you.
This thread isn't actually relevant anymore since the changes we requested were eventually made some time after beta 3.
Loading...
