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.

eventsManager not AUTO Injected into a component ?

I declare a subclass of Phalcon\Mvc\User\Component but the getEventsManager return null? is the eventsManager not auto injected? or I must inject it by myself? @phalcon


You're right, you need to inject it yourself.

\Phalcon\Mvc\User\Component implements both \Phalcon\Di\InjectionAwareInterface and \Phalcon\Events\EventsAwareInterface. The first provides you with setDI($di) and the second with setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager), so you can set them and use them accordingly, but no they're not provided by default.