@@ -108,7 +108,8 @@ |
||
| 108 | 108 | } else { |
| 109 | 109 | $autohandlers = []; |
| 110 | 110 | |
| 111 | - foreach ($methods as $method) { // slow |
|
| 111 | + foreach ($methods as $method) { |
|
| 112 | +// slow |
|
| 112 | 113 | //extract the event name from the method name |
| 113 | 114 | $eventName = lcfirst(substr($method->name, 2)); |
| 114 | 115 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | // filter out any that don't begin with "on" |
| 100 | 100 | $methods = array_filter( |
| 101 | 101 | $methods, |
| 102 | - function (\ReflectionMethod $m) { |
|
| 102 | + function(\ReflectionMethod $m) { |
|
| 103 | 103 | return (strpos($m->name, 'on') === 0); |
| 104 | 104 | } |
| 105 | 105 | ); // slow, both array_filter and closure |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | // filter out auto-handlers so that a subsequent call to subscribe() |
| 156 | 156 | // works predictably |
| 157 | - $this->handlers = array_filter($this->handlers, function ($v) { |
|
| 157 | + $this->handlers = array_filter($this->handlers, function($v) { |
|
| 158 | 158 | return (strpos($v[0][1], 'on') !== 0); |
| 159 | 159 | }); |
| 160 | 160 | |
@@ -17,7 +17,8 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class Fancify extends Noair\Observer |
| 19 | 19 | { |
| 20 | - public function onCreatePost(Event $event) { |
|
| 20 | + public function onCreatePost(Event $event) |
|
| 21 | + { |
|
| 21 | 22 | return str_replace('border:1px solid #EEE;', |
| 22 | 23 | 'border:1px solid #DADADA;background:#F1F1F1;font-family:Arial;font-size:15px;', |
| 23 | 24 | $event->previousResult); |
@@ -16,7 +16,8 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | class Formatter extends Noair\Observer |
| 18 | 18 | { |
| 19 | - public function subscribe() { |
|
| 19 | + public function subscribe() |
|
| 20 | + { |
|
| 20 | 21 | // This is just here for an example of explicitly-defined handlers |
| 21 | 22 | $this->handlers = [ |
| 22 | 23 | 'formatUsername' => [[$this, 'formatUsername']], |
@@ -28,24 +29,29 @@ discard block |
||
| 28 | 29 | return parent::subscribe(); |
| 29 | 30 | } |
| 30 | 31 | |
| 31 | - public function formatUsername(Event $event) { |
|
| 32 | + public function formatUsername(Event $event) |
|
| 33 | + { |
|
| 32 | 34 | return $event->data; |
| 33 | 35 | } |
| 34 | 36 | |
| 35 | - public function formatGroup(Event $event) { |
|
| 37 | + public function formatGroup(Event $event) |
|
| 38 | + { |
|
| 36 | 39 | return $event->data; |
| 37 | 40 | } |
| 38 | 41 | |
| 39 | - public function formatMessage(Event $event) { |
|
| 42 | + public function formatMessage(Event $event) |
|
| 43 | + { |
|
| 40 | 44 | return nl2br($event->data); |
| 41 | 45 | } |
| 42 | 46 | |
| 43 | - public function formatDate(Event $event) { |
|
| 47 | + public function formatDate(Event $event) |
|
| 48 | + { |
|
| 44 | 49 | // return date('F j, Y h:i:s A', $event->data); |
| 45 | 50 | return ''; |
| 46 | 51 | } |
| 47 | 52 | |
| 48 | - public function onCreatePost(Event $event) { |
|
| 53 | + public function onCreatePost(Event $event) |
|
| 54 | + { |
|
| 49 | 55 | $result = '<div style="padding: 9px 16px;border:1px solid #EEE;margin-bottom:16px;">' |
| 50 | 56 | .'<strong>Posted by</strong> ' |
| 51 | 57 | .$this->mediator->publish(new Event('formatUsername', $event->data['username'], $this)) |
@@ -17,7 +17,8 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | class BetterFormatter extends Noair\Observer |
| 19 | 19 | { |
| 20 | - public function onFormatGroup(Event $event) { |
|
| 20 | + public function onFormatGroup(Event $event) |
|
| 21 | + { |
|
| 21 | 22 | $groupName = strtolower($event->data); |
| 22 | 23 | |
| 23 | 24 | switch ($groupName): |
@@ -35,7 +36,8 @@ discard block |
||
| 35 | 36 | return $groupName; |
| 36 | 37 | } |
| 37 | 38 | |
| 38 | - public function onFormatDate(Event $event) { |
|
| 39 | + public function onFormatDate(Event $event) |
|
| 40 | + { |
|
| 39 | 41 | return date('F j, Y h:i:s A T', $event->data); |
| 40 | 42 | } |
| 41 | 43 | } |
@@ -17,7 +17,8 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class FancyExamplePlugin extends Noair\Observer |
| 19 | 19 | { |
| 20 | - public function onFormatMessage(Event $event) { |
|
| 20 | + public function onFormatMessage(Event $event) |
|
| 21 | + { |
|
| 21 | 22 | $message = strip_tags($event->data); |
| 22 | 23 | $message = preg_replace('/\[b\](.+?)\[\/b\]/is', '<span style="font-weight:bold">$1</span>', $message); |
| 23 | 24 | $message = preg_replace('/\[u\](.+?)\[\/u\]/is', '<span style="text-decoration:underline">$1</span>', $message); |
@@ -265,7 +265,7 @@ |
||
| 265 | 265 | // scaffold if not exist |
| 266 | 266 | if (!$this->hasSubscribers($eventName)) { |
| 267 | 267 | $this->subscribers[$eventName] = [ |
| 268 | - [ // insert positions |
|
| 268 | + [// insert positions |
|
| 269 | 269 | self::PRIORITY_URGENT => 1, |
| 270 | 270 | self::PRIORITY_HIGHEST => 1, |
| 271 | 271 | self::PRIORITY_HIGH => 1, |