src/CI_Base_Model.php
protected function subscribe($event, $observer, $handler = FALSE)
    {
        if (!isset($this->event_listeners[$event])) {
            $this->event_listeners[$event] = array();
        }

        if (is_string($handler) || (is_string($observer) && !$handler)) {
            $handler = !$handler ? $observer : $handler;
            $this->event_listeners[$event][$handler] = $observer;
            return $this;
        }

        $strategy = $handler ? 'array_unshift' : 'array_push';

        $strategy($this->event_listeners[$event], $observer);

        return $this;
    }
protected function subscribe($event, $observer, $handler = FALSE)
    {
        if (!isset($this->event_listeners[$event])) {
            $this->event_listeners[$event] = array();
        }

        if (is_string($handler) || (is_string($observer) && !$handler)) {
            $handler = !$handler ? $observer : $handler;
            $this->event_listeners[$event][$handler] = $observer;
            return $this;
        }

        $strategy = $handler ? 'array_unshift' : 'array_push';

        $strategy($this->event_listeners[$event], $observer);

        return $this;
    }
/*---------------------------
Event Callback functions
---------------------------