Created
February 17, 2015 13:02
-
-
Save rizqidjamaluddin/64f38174cc9eb78e1792 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MailNotifier implements Notifier { | |
public function notify (Notification $n, Closure $next) { | |
Mail::send(); // ... whatever | |
return $next($n); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PusherNotifier implements Notifier { | |
public function notify (Notification $n, Closure $next) { | |
Pusher::push($n->recepient()->getOption('pusher.id'), $n->getPayload()); | |
return $next($n); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// in an event listener for when a chat reply goes out | |
foreach ($chatroom->users() as $user) { | |
if ($user != $event->author()) { // prevet message author from getting it | |
$user->notify(new ChatReplyNotification($event->message(), $event->author())); // just a DTO | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class User { | |
public function notify (Notification $n) { | |
$notifier = NotifierFactory::buildStack($this->getNotificationOptions()); // builds the notification stack | |
$notifier->notify($n); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment