@@ 34-49 (lines=16) @@ | ||
31 | * @param mixed ...$args Arguments |
|
32 | * @return this |
|
33 | */ |
|
34 | public function event() { |
|
35 | $args = func_get_args(); |
|
36 | $name = array_shift($args); |
|
37 | if ($this->addThisToEvents) { |
|
38 | array_unshift($args, $this); |
|
39 | } |
|
40 | if (isset($this->eventHandlers[$name])) { |
|
41 | $this->lastEventName = $name; |
|
42 | foreach ($this->eventHandlers[$name] as $cb) { |
|
43 | if (call_user_func_array($cb, $args) === true) { |
|
44 | return $this; |
|
45 | } |
|
46 | } |
|
47 | } |
|
48 | return $this; |
|
49 | } |
|
50 | ||
51 | /** |
|
52 | * Propagate event |
|
@@ 57-72 (lines=16) @@ | ||
54 | * @param mixed ...$args Arguments |
|
55 | * @return this |
|
56 | */ |
|
57 | public function trigger() { |
|
58 | $args = func_get_args(); |
|
59 | $name = array_shift($args); |
|
60 | if ($this->addThisToEvents) { |
|
61 | array_unshift($args, $this); |
|
62 | } |
|
63 | if (isset($this->eventHandlers[$name])) { |
|
64 | $this->lastEventName = $name; |
|
65 | foreach ($this->eventHandlers[$name] as $cb) { |
|
66 | if (call_user_func_array($cb, $args) === true) { |
|
67 | return $this; |
|
68 | } |
|
69 | } |
|
70 | } |
|
71 | return $this; |
|
72 | } |
|
73 | ||
74 | /** |
|
75 | * Propagate event |