@@ 34-41 (lines=8) @@ | ||
31 | public function attach($owner) |
|
32 | { |
|
33 | $this->owner = $owner; |
|
34 | foreach ($this->notifications as $event => $notifications) { |
|
35 | if (!is_array($notifications)) { |
|
36 | $notifications = [$notifications]; |
|
37 | } |
|
38 | foreach ($notifications as $notification) { |
|
39 | $owner->on($event, [$this, 'handle'], ['notification' => $notification]); |
|
40 | } |
|
41 | } |
|
42 | } |
|
43 | ||
44 | /** |
|
@@ 50-57 (lines=8) @@ | ||
47 | public function detach() |
|
48 | { |
|
49 | if ($this->owner) { |
|
50 | foreach ($this->notifications as $event => $notifications) { |
|
51 | if (!is_array($notifications)) { |
|
52 | $notifications = [$notifications]; |
|
53 | } |
|
54 | foreach ($notifications as $notification) { |
|
55 | $this->owner->off($event, [$this, 'handle']); |
|
56 | } |
|
57 | } |
|
58 | $this->owner = null; |
|
59 | } |
|
60 | } |