How Core Uses The Events

Hi.

I just wanted to ask why are you not using events as widely as possible?

Because of performance reasons?

I am talking about presence of the ->trigger(EVENT_NAME) more often in the core.

For example in the end of Module::init one could trigger MODULE_INIT event.

And so I could tune any module via it’s config array.

Now I am expected to override this init method for my module to do some initial work.

And one could possibly think of a lot of places inside framework where it could be used the same way. Like this:

UrlManager::EVENT_BEFORE_CREATE_URL

UrlManager::EVENT_AFTER_CREATE_URL

Overriding method is preferred because of it’s much more easy to read and debug and, of course, a bit more performant. If you’ve missing events you need, add issues to github with your use cases and we’ll consider adding these.

understood.

I am not missing any particular event right now, I just spotted that some receipts I saw in the wiki could be implemented a little easily if there was event from the core.

+1