Example #1
0
 /**
  * Sends a notification to some players
  *
  * @param mixed    $players A single player/ID or a player/ID list
  * @param string   $type   The type of the event
  * @param null|\Player|int $except A player who should not receive a notification
  * @param \Player $except
  */
 protected function doNotify($players, $type, $except = null)
 {
     Debug::log("Notifying about {$type}", array('players' => $players, 'except' => $except));
     if ($except instanceof \Player) {
         $except = $except->getId();
     }
     if (!is_array($players)) {
         $players = array($players);
     }
     foreach ($players as $player) {
         if ($player instanceof \Player) {
             $player = $player->getId();
         }
         if ($player != $except) {
             $notification = \Notification::newNotification($player, $type, $this);
             \Service::getContainer()->get('event_dispatcher')->dispatch(Events::NOTIFICATION_NEW, new NewNotificationEvent($notification));
         }
     }
 }