1/*
2 Example 1:
3 event::bind('blog.post.create', function($args = array())
4 {
5 mail('myself@me.com', 'Blog Post Published', $args['name'] . ' has been published');
6});
7
8 Example 2:
9 event::trigger('blog.post.create', $postInfo);
10*/
11
12class event
13{
14 public static $events = array();
15
16 public static function trigger($event, $args = array())
17 {
18 if(isset(self::$events[$event]))
19 {
20 foreach(self::$events[$event] as $func)
21 {
22 call_user_func($func, $args);
23 }
24 }
25
26 }
27
28 public static function bind($event, Closure $func)
29 {
30 self::$events[$event][] = $func;
31 }
32}
33