CodeIgniter Forums

Full Version: Event Triggering for Codeigniter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]riwakawd[/eluser]
I would like to know if it is possible to use open cart events trigger and convert it with codeigniter

Because I would like to use it in one of my model functions. What would I need to do? I have my database cache set up.

If there is some thing similar to this all ready done with codeigniter please let me know cheers.

Model example

Code:
public function editStore($website_id, $data) {

$this->event->trigger('pre_admin_edit_store', $data);

some->query->code();

$this->cache->delete('website');

$this->event->trigger('admin_edit_store');

}

Events lib. // Not sure if will work from open cart to codeigniter lib.

Code:
class Events {

  public function trigger($event, &$data = array()) {
        if (!array_key_exists($event, $this->events)) {
            return true;
        }

        foreach ($this->events[$event] as $handler) {
            $parts = explode('/', $handler);

            $event = $this->load->event($parts[0] . '/' . $parts[1]);

            if (is_callable(array($event, $parts[2]))) {
                $event->{$parts[2]}($data);
            }
        }

        return true;
    }
}

El Forum

[eluser]InsiteFX[/eluser]
CodeIgniter Events Library:

Events Library