seeddms-code/inc/inc.ClassNotificationService.php

67 lines
1.9 KiB
PHP
Raw Normal View History

2016-03-09 16:57:38 +00:00
<?php
/**
* Implementation of notification service
*
* @category DMS
* @package SeedDMS
* @license GPL 2
* @version @version@
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2016 Uwe Steinmann
* @version Release: @package_version@
*/
/**
* Implementation of notification service
*
* @category DMS
* @package SeedDMS
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2016 Uwe Steinmann
* @version Release: @package_version@
*/
class SeedDMS_NotificationService {
/**
* List of services for sending notification
*/
protected $services;
public function __construct() {
$this->services = array();
}
public function addService($service, $name='') {
$this->services[$name ? $name : md5(uniqid())] = $service;
}
public function getServices() {
return $this->services;
2016-03-09 16:57:38 +00:00
}
public function toIndividual($sender, $recipient, $subject, $message, $params=array()) {
foreach($this->services as $name => $service) {
if(!is_callable([$service, 'filter']) || $service->filter($sender, $recipient, $subject, $message, $params)) {
return $service->toIndividual($sender, $recipient, $subject, $message, $params);
}
2016-03-09 16:57:38 +00:00
}
}
public function toGroup($sender, $groupRecipient, $subject, $message, $params=array()) {
foreach($this->services as $name => $service) {
if(!is_callable([$service, 'filter']) || $service->filter($sender, $groupRecipient, $subject, $message, $params)) {
return $service->toGroup($sender, $groupRecipient, $subject, $message, $params);
}
2016-03-09 16:57:38 +00:00
}
}
public function toList($sender, $recipients, $subject, $message, $params=array()) {
foreach($this->services as $name => $service) {
if(!is_callable([$service, 'filter']) || $service->filter($sender, $recipients, $subject, $message, $params)) {
return $service->toList($sender, $recipients, $subject, $message, $params);
}
2016-03-09 16:57:38 +00:00
}
}
}