XF 2.2 Call message in static method

FoxSecrets

Active member
How to call message method inside a static method?
This also extends for error, redirect, buildlink, etc, getting undefined method.

Code:
\XF::app()->message(\XF::phrase('some message'));
 
Last edited:
Those are class members of a controller. They're not available on the app container. What are you trying to achieve?
 
I'm trying to run a cron which method is static and it's calling another method in controller.
Anyway, I got your point. I'll implement my own container then. Thank you!
 
You can peak at the core to see how things are achieved, but again most of the real logic is abstracted into services (\XF\Service\**) and the controllers just call into those. Creating a service will allow you to reuse logic between different controllers, apps, jobs, etc. Working with the IoC container directly is mostly reserved for instantiating brand new classes that don't fit into an existing paradigm.

Also worth noting cron runs in the background using the job queue so using reply objects (redirects, messages, etc.) doesn't really make a lot of sense there.
 
Top Bottom