Skip to content

Instantly share code, notes, and snippets.

@rizqidjamaluddin
Created February 17, 2015 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rizqidjamaluddin/64f38174cc9eb78e1792 to your computer and use it in GitHub Desktop.
Save rizqidjamaluddin/64f38174cc9eb78e1792 to your computer and use it in GitHub Desktop.
<?php
class MailNotifier implements Notifier {
public function notify (Notification $n, Closure $next) {
Mail::send(); // ... whatever
return $next($n);
}
}
<?php
class PusherNotifier implements Notifier {
public function notify (Notification $n, Closure $next) {
Pusher::push($n->recepient()->getOption('pusher.id'), $n->getPayload());
return $next($n);
}
}
<?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
}
}
<?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