Skip to content
No description or website provided.
Find file
Pull request Compare This branch is even with Zeelot:1.0.x/develop.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Kohana Event Dispatcher

A simple events-system for Kohana 3.x.

  • Author: Jeremy Lindblom (jeremeamia)
  • Version: 0.1
  • Compatible Kohana Version(s): 3.1.x


Currently untested. Not for production use.

Sample Usage

In this example, the event dispatcher will be used to implement part of a user rewards system. In this case, a Rewarder object listens for an event signifying the someone has accepted a Referral to the application. The rewarder then rewards the referrer a specific amount of points.


$dispatcher = Event_Dispatcher::factory()

Triggering an Event

class Referral {
    protected $_dispatcher;
    /* ... */

    public function __construct(/* ... */, Interface_Dispatcher $dispatcher)
        /* ... */
        $this->_dispatcher = $dispatcher;

    /* ... */

    public function accept()
        /* ... */
        $this->_dispatcher->trigger('referral.accepted', new Event($this));
        /* ... */

Handling the Event

class Subscriber_Rewarder implements Interface_Subscriber {
    public function get_listeners()
        return array(
            'referral.accepted' => array($this, 'referral'),

    public function referral(Interface_Event $event)
        $referral = $event->get_subject();
        if ($referral instanceof Referral)
            $points = Kohana::config('rewards.points.referral');
Something went wrong with that request. Please try again.