3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * Test SMS provider to allow for testing
15 class CiviTestSMSProvider
extends CRM_SMS_Provider
{
16 protected $_providerInfo = [];
18 static private $_singleton = [];
20 public function __construct($provider, $skipAuth = TRUE) {
21 $this->provider
= $provider;
24 public static function &singleton($providerParams = [], $force = FALSE) {
25 if (isset($providerParams['provider'])) {
26 $providers = CRM_SMS_BAO_Provider
::getProviders(NULL, array('name' => $providerParams['provider']));
27 $provider = current($providers);
28 $providerID = $provider['id'] ??
NULL;
31 $providerID = $providerParams['provider_id'] ??
NULL;
33 $skipAuth = $providerID ?
FALSE : TRUE;
34 $cacheKey = (int) $providerID;
36 if (!isset(self
::$_singleton[$cacheKey]) ||
$force) {
39 $provider = CRM_SMS_BAO_Provider
::getProviderInfo($providerID);
41 self
::$_singleton[$cacheKey] = new CiviTestSMSProvider($provider, $skipAuth);
43 return self
::$_singleton[$cacheKey];
46 public function send($recipients, $header, $message, $dncID = NULL) {