tags:

views:

411

answers:

2

I'm trying to understand the event system of Kohana. The only thing i don't understand is, where to place the Event::add code.

It should be in a place where it is executed before any events are fired. Or am I missing something?

What i want to achieve is to construct a class that is available everywhere, but don't realy want to hack it into Kohana.

Can anyone cast a light on this?

+2  A: 

Try adding in a hook with your Event::Add code.

From the documentation:

The power of hooks mainly comes from the Events class. Hooks are loaded before any of the events are started so you can attach a hook to an event

Phill Sacre
I'll look into that. Thx
Ikke
A: 

Usually Event::add() and Event::replace() are placed in the Hook constructor. Hooks are loaded before the first event of system ('system.ready') so you can add your callback to every system or custom event.