@@ 40-47 (lines=8) @@ | ||
37 | public function attach($owner) |
|
38 | { |
|
39 | $this->owner = $owner; |
|
40 | foreach ($this->notifications as $event => $notifications) { |
|
41 | if (!is_array($notifications)) { |
|
42 | $notifications = [$notifications]; |
|
43 | } |
|
44 | foreach ($notifications as $notification) { |
|
45 | $owner->on($event, [$this, 'handle'], ['notification' => $notification]); |
|
46 | } |
|
47 | } |
|
48 | } |
|
49 | ||
50 | /** |
|
@@ 56-63 (lines=8) @@ | ||
53 | public function detach() |
|
54 | { |
|
55 | if ($this->owner) { |
|
56 | foreach ($this->notifications as $event => $notifications) { |
|
57 | if (!is_array($notifications)) { |
|
58 | $notifications = [$notifications]; |
|
59 | } |
|
60 | foreach ($notifications as $notification) { |
|
61 | $this->owner->off($event, [$this, 'handle']); |
|
62 | } |
|
63 | } |
|
64 | $this->owner = null; |
|
65 | } |
|
66 | } |