Skip to content
This repository was archived by the owner on Nov 26, 2020. It is now read-only.

Commit d4f98d8

Browse files
authored
Merge pull request #4 from azijul1/master
Changes in dial, menu and filter Tag to change the inner call flow
2 parents bb380fa + 5e072fd commit d4f98d8

4 files changed

Lines changed: 61 additions & 14 deletions

File tree

example/dial.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
require(__DIR__.'/../vendor/autoload.php');
3+
4+
$response = new Mobtexting\Voice();
5+
$response->answer();
6+
$dial = $response->dial("+91720414xxxx", "+91803007xxxx"); // customer number, DID number
7+
$dial->onNoAnswer("dial", array("+9172xxxx", "+9180xxxx")); // customer number, DID number
8+
9+
10+
//print_r($response->toArray());
11+
12+
echo $response;

src/Voice/Tag/Dial.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,34 @@ public function __construct($to, $from = null)
1717
parent::__construct("Dial", $attrib);
1818
}
1919

20-
public function onAnswer($tag, $attribs = [])
20+
public function onAnswer($tag, $attribs = [], $isSequential = false)
2121
{
22-
return $this->setAttribute('onanswer', $this->append($tag, $attribs), true);
22+
if($isSequential){
23+
$this->attributes['onanswer'] = array_merge($this->attributes['onanswer'], array($this->append($tag, $attribs)) );
24+
return $this->attributes;
25+
}else {
26+
return $this->setAttribute('onanswer', array($this->append($tag, $attribs)), true);
27+
}
2328
}
2429

25-
public function onNoAnswer($tag, $attribs = [])
30+
public function onNoAnswer($tag, $attribs = [], $isSequential = false)
2631
{
27-
return $this->setAttribute('onnoanswer', $this->append($tag, $attribs), true);
32+
if($isSequential){
33+
$this->attributes['onnoanswer'] = array_merge($this->attributes['onnoanswer'], array($this->append($tag, $attribs)) );
34+
return $this->attributes;
35+
}else {
36+
return $this->setAttribute('onnoanswer', array($this->append($tag, $attribs)), true);
37+
}
2838
}
2939

30-
public function noAnswer($tag, $attribs = [])
40+
public function noAnswer($tag, $attribs = [], $isSequential = false)
3141
{
32-
return $this->setAttribute('onnoanswer', $this->append($tag, $attribs), true);
42+
if($isSequential){
43+
$this->attributes['onnoanswer'] = array_merge($this->attributes['onnoanswer'], array($this->append($tag, $attribs)) );
44+
return $this->attributes;
45+
}else {
46+
return $this->setAttribute('onnoanswer', array($this->append($tag, $attribs)), true);
47+
}
3348
}
3449

3550
public function getDefaultAttributes()

src/Voice/Tag/Filter.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,24 @@ public function __construct($data = null, $type = 'frequency')
3030
parent::__construct("Filter", ['type' => $type, $unit => $data]);
3131
}
3232

33-
public function onFail($tag, $attribs = [])
33+
public function onFail($tag, $attribs = [], $isSequential = false)
3434
{
35-
return $this->setAttribute('onfail', $this->append($tag, $attribs), true);
35+
if($isSequential){
36+
$this->attributes['onfail'] = array_merge($this->attributes['onfail'], array($this->append($tag, $attribs)) );
37+
return $this->attributes;
38+
}else {
39+
return $this->setAttribute('onfail', array($this->append($tag, $attribs)), true);
40+
}
3641
}
3742

38-
public function onPass($tag, $attribs = [])
43+
public function onPass($tag, $attribs = [], $isSequential = false)
3944
{
40-
return $this->setAttribute('onpass', $this->append($tag, $attribs), true);
45+
if($isSequential){
46+
$this->attributes['onpass'] = array_merge($this->attributes['onpass'], array($this->append($tag, $attribs)) );
47+
return $this->attributes;
48+
}else {
49+
return $this->setAttribute('onpass', array($this->append($tag, $attribs)), true);
50+
}
4151
}
4252

4353
public function getDefaultAttributes()

src/Voice/Tag/Menu.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,24 @@ public function __construct($prompt, $attribs = [])
1818
parent::__construct("Menu", $attribs);
1919
}
2020

21-
public function onFail($verb, $attribs = [])
21+
public function onFail($verb, $attribs = [], $isSequential = false)
2222
{
23-
return $this->setAttribute('onFail', $this->append($verb, $attribs), true);
23+
if($isSequential){
24+
$this->attributes['onfail'] = array_merge($this->attributes['onfail'], array($this->append($verb, $attribs)) );
25+
return $this->attributes;
26+
}else {
27+
return $this->setAttribute('onfail', array($this->append($verb, $attribs)), true);
28+
}
2429
}
2530

26-
public function onTimeout($verb, $attribs = [])
31+
public function onTimeout($verb, $attribs = [], $isSequential = false)
2732
{
28-
return $this->setAttribute('timeout', $this->append($verb, $attribs), true);
33+
if($isSequential){
34+
$this->attributes['timeout'] = array_merge($this->attributes['timeout'], array($this->append($verb, $attribs)) );
35+
return $this->attributes;
36+
}else {
37+
return $this->setAttribute('timeout', array($this->append($verb, $attribs)), true);
38+
}
2939
}
3040

3141
public function getDefaultAttributes()

0 commit comments

Comments
 (0)