Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

injectionAwareInterface auto inject not working?

DI not getting auto injected on class implimenting injectionAwareInterface?

I've implimented the method, then when I call the class, the di is null, is there anything else needed for it to auto inject itself?


Ok, I see how it's done, the DI will only autoinject itself, if you call the class from the DI,

For anyone else who is interested, means you need to define your class as a service and resolve it with DI instead of manually,


$bannerModule = new BannerModule(); //  This will not have the DI injected to it

$di->set('bannerModule', function() {
    return new BannerModule(); 

$di->get('bannerModule'); // This will have the DI injected to it

Hope this helps someone else too.