From 6d84ac1a9abcb94eb10d6a7d4dd9eb45408a6f7b Mon Sep 17 00:00:00 2001 From: jaren Date: Wed, 8 Mar 2017 11:33:04 +0800 Subject: [PATCH] =?UTF-8?q?#1=20=E6=9B=B4=E6=94=B9=20helper=20=E7=B1=BB?= =?UTF-8?q?=E5=90=8D=E4=B8=BA=E5=A4=A7=E5=86=99=20Helper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lib/Alidayu/{helper.php => Helper.php} | 2 +- Lib/Ucpaas/{helper.php => Helper.php} | 2 +- Service/SmsService.class.php | 26 +++++++++++++------------- 3 files changed, 15 insertions(+), 15 deletions(-) rename Lib/Alidayu/{helper.php => Helper.php} (97%) rename Lib/Ucpaas/{helper.php => Helper.php} (97%) diff --git a/Lib/Alidayu/helper.php b/Lib/Alidayu/Helper.php similarity index 97% rename from Lib/Alidayu/helper.php rename to Lib/Alidayu/Helper.php index cbe7ca3..3f28393 100644 --- a/Lib/Alidayu/helper.php +++ b/Lib/Alidayu/Helper.php @@ -2,7 +2,7 @@ namespace Sms\Lib\Alidayu; -class helper{ +class Helper{ public function send($conf,$to, $param){ $c = new TopClient; diff --git a/Lib/Ucpaas/helper.php b/Lib/Ucpaas/Helper.php similarity index 97% rename from Lib/Ucpaas/helper.php rename to Lib/Ucpaas/Helper.php index 624cf85..2c5c750 100644 --- a/Lib/Ucpaas/helper.php +++ b/Lib/Ucpaas/Helper.php @@ -2,7 +2,7 @@ namespace Sms\Lib\Ucpaas; -class helper{ +class Helper{ protected $conf; diff --git a/Service/SmsService.class.php b/Service/SmsService.class.php index 5242191..1d95c8f 100644 --- a/Service/SmsService.class.php +++ b/Service/SmsService.class.php @@ -28,31 +28,31 @@ class SmsService { public static function sendSms($template, $to, $param = NULL, $operator = NULL) { - //如果没有传入短信平台,则使用 default 短信平台发送 - if (null == $operator){ - $operator = M('smsOperator')->where("enable='1'")->find()['tablename']; - } + //如果没有传入短信平台,则使用后台配置的开启的短信平台发送 + if (null == $operator){ + $operator = M('smsOperator')->where("enable='1'")->find()['tablename']; + } - // if param is not a json string, make it to json + // 如果传入数据不是 json 字符串,将其转化为 json 字符串 if (is_array($param)) { - // make sure every param is a instance of string - foreach($param as $k => $v){ - $param[$k] = $v . ""; - } + // 保证所有的参数都是字符串类型 + foreach($param as $k => $v){ + $param[$k] = $v . ""; + } $param = json_encode($param); } - //get sms operator configure + // 获取短信模板配置 $model = M('sms_' . $operator); $conf = $model->find($template); //检查是否存在指定的文件 - $file = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "Lib" . DIRECTORY_SEPARATOR . ucfirst($operator) . DIRECTORY_SEPARATOR."helper.php"; + $file = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "Lib" . DIRECTORY_SEPARATOR . ucfirst($operator) . DIRECTORY_SEPARATOR."Helper.php"; if (file_exists($file)) { //导入当前模块下Lib目录下的指定文件 - require_once(PROJECT_PATH . "Application/Sms/Lib/" . ucfirst($operator) . "/helper.php"); - $className = "\\Sms\\Lib\\" . ucfirst($operator) . "\\helper"; + require_once(PROJECT_PATH . "Application/Sms/Lib/" . ucfirst($operator) . "/Helper.php"); + $className = "\\Sms\\Lib\\" . ucfirst($operator) . "\\Helper"; $helper = new $className(); $result = json_encode($helper->send($conf, $to, $param));