mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 12:02:24 +09:00
Allow adding arbitrary extra vars to SMS
This commit is contained in:
parent
98b32a2572
commit
f4c4ec5ec6
3 changed files with 63 additions and 0 deletions
|
|
@ -99,6 +99,10 @@ class CoolSMS extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
||||||
{
|
{
|
||||||
$options->image = $message->image;
|
$options->image = $message->image;
|
||||||
}
|
}
|
||||||
|
foreach ($original->getExtraVars() as $key => $value)
|
||||||
|
{
|
||||||
|
$options->$key = $value;
|
||||||
|
}
|
||||||
$result = $sender->send($options);
|
$result = $sender->send($options);
|
||||||
if (!$result->success_count)
|
if (!$result->success_count)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ class SMS
|
||||||
protected $subject = '';
|
protected $subject = '';
|
||||||
protected $content = '';
|
protected $content = '';
|
||||||
protected $attachments = array();
|
protected $attachments = array();
|
||||||
|
protected $extra_vars = array();
|
||||||
protected $delay_timestamp = 0;
|
protected $delay_timestamp = 0;
|
||||||
protected $force_sms = false;
|
protected $force_sms = false;
|
||||||
protected $allow_split_sms = true;
|
protected $allow_split_sms = true;
|
||||||
|
|
@ -323,6 +324,51 @@ class SMS
|
||||||
return $this->attachments;
|
return $this->attachments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set an extra variable.
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param mixed $value
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setExtraVar($key, $value)
|
||||||
|
{
|
||||||
|
$this->extra_vars[$key] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an extra variable.
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getExtraVar($key)
|
||||||
|
{
|
||||||
|
return isset($this->extra_vars[$key]) ? $this->extra_vars[$key] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all extra variables.
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getExtraVars()
|
||||||
|
{
|
||||||
|
return $this->extra_vars;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set all extra variables.
|
||||||
|
*
|
||||||
|
* @param array $vars
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setExtraVars(array $vars)
|
||||||
|
{
|
||||||
|
$this->extra_vars = $vars;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delay sending the message.
|
* Delay sending the message.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,19 @@ class SMSTest extends \Codeception\TestCase\Test
|
||||||
$this->assertEquals('minify.target.css', $attachments[1]->display_filename);
|
$this->assertEquals('minify.target.css', $attachments[1]->display_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSMSExtraVars()
|
||||||
|
{
|
||||||
|
$sms = new Rhymix\Framework\SMS;
|
||||||
|
|
||||||
|
$sms->setExtraVar('foo', 'bar');
|
||||||
|
$this->assertEquals('bar', $sms->getExtraVar('foo'));
|
||||||
|
$this->assertNull($sms->getExtraVar('nonexistent!'));
|
||||||
|
$sms->setExtraVar('baz', 'moo');
|
||||||
|
$this->assertEquals(array('foo' => 'bar', 'baz' => 'moo'), $sms->getExtraVars());
|
||||||
|
$sms->setExtraVars(array('rhymix' => 'test'));
|
||||||
|
$this->assertEquals(array('rhymix' => 'test'), $sms->getExtraVars());
|
||||||
|
}
|
||||||
|
|
||||||
public function testSMSDelay()
|
public function testSMSDelay()
|
||||||
{
|
{
|
||||||
$sms = new Rhymix\Framework\SMS;
|
$sms = new Rhymix\Framework\SMS;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue