/** * Initialise the plugin and register all events that were defined in $this->_events. * * @return Kohana_Plugin * @throws Kohana_Exception */ public final function init() { if ($this->_init() == true) { if (count($this->_events) > 0) { foreach ($this->_events as $id => $event) { $class_event = Valid::digit($id) ? str_replace('.', '_', $event) : $id; Plug::listen($event, array($this, 'on_' . $class_event)); } } return $this; } else { throw new Kohana_Exception('Failed to initialise the ":plugin" plugin', array(':plugin' => $this->info['name'])); } }