/**
  * Send a notification via email to the selected users
  *
  * @param SystemNotification	$notification
  * @param DataObject			$context
  * @param array					$data
  */
 public function sendNotification($notification, $context, $data)
 {
     $users = $notification->getRecipients($context);
     foreach ($users as $user) {
         $this->sendToUser($notification, $context, $user, $data);
     }
 }
 /**
  * Send out a notification
  *
  * @param SystemNotification $notification
  *				The configured notification object
  * @param DataObject $context
  *				The context of the notification to send
  * @param array $extraData
  *				Any extra data to add into the notification text
  * @param string $channel
  *				A specific channel to send through. If not set, just sends to the default configured
  */
 public function sendNotification(SystemNotification $notification, DataObject $context, $extraData = array(), $channel = null)
 {
     // check to make sure that there are users to send it to. If not, we don't bother with it at all
     $recipients = $notification->getRecipients($context);
     if (!count($recipients)) {
         return;
     }
     // if we've got queues and a large number of recipients, lets send via a queued job instead
     if ($this->config()->get('use_queues') && count($recipients) > 5) {
         $extraData['SEND_CHANNEL'] = $channel;
         singleton('QueuedJobService')->queueJob(new SendNotificationJob($notification, $context, $extraData));
     } else {
         $channels = $channel ? array($channel) : $this->channels;
         foreach ($channels as $channel) {
             if ($sender = $this->getSender($channel)) {
                 $sender->sendNotification($notification, $context, $extraData);
             }
         }
     }
 }