• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Event Triggering for Codeigniter

#1
[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;
    }
}

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

Events Library


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.