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

Commit eb3f7ae

Browse files
committed
Testing All widgets
1 parent 92a018d commit eb3f7ae

3 files changed

Lines changed: 38 additions & 20 deletions

File tree

src/Voice/Tag/Dial.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,16 @@ public function __construct($to, $from = null)
1919

2020
public function onAnswer($tag, $attribs = [])
2121
{
22-
return $this->setAttribute('onanswer', $this->append($tag, $attribs), true);
22+
$new_tag = $this->append($tag, $attribs);
23+
$this->setAttribute('onanswer', array($new_tag), false);
24+
return $new_tag;
2325
}
2426

2527
public function onNoAnswer($tag, $attribs = [])
2628
{
27-
return $this->setAttribute('onnoanswer', $this->append($tag, $attribs), true);
28-
}
29-
30-
public function noAnswer($tag, $attribs = [])
31-
{
32-
return $this->setAttribute('onnoanswer', $this->append($tag, $attribs), true);
29+
$new_tag = $this->append($tag, $attribs);
30+
$this->setAttribute('onnoanswer', array($new_tag), false);
31+
return $new_tag;
3332
}
3433

3534
public function getDefaultAttributes()

src/Voice/Tag/Menu.php

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,47 @@ class Menu extends Voice
1313
'onfail'
1414
];
1515

16-
public function __construct($prompt, $attribs = [])
16+
public function __construct($prompt = null, $attribs = [])
1717
{
18+
if ($prompt) {
19+
if (is_array($prompt)) {
20+
$attribs = array_merge($prompt, $attribs);
21+
} else {
22+
$attribs['prompt'] = $prompt;
23+
}
24+
}
25+
1826
parent::__construct("Menu", $attribs);
1927
}
2028

2129
public function onFail($verb, $attribs = [])
2230
{
23-
return $this->setAttribute('onFail', $this->append($verb, $attribs), true);
31+
$new_tag = $this->append($verb, $attribs);
32+
$this->setAttribute('onfail', array($new_tag), false);
33+
return $new_tag;
34+
}
35+
36+
public function onKeyPress($key, $verb, $attribs = [])
37+
{
38+
$new_tag = $this->append($verb, $attribs);
39+
$this->setAttribute($key, array($new_tag), false);
40+
return $new_tag;
2441
}
2542

2643
public function onTimeout($verb, $attribs = [])
2744
{
28-
return $this->setAttribute('timeout', $this->append($verb, $attribs), true);
45+
$new_tag = $this->append($verb, $attribs);
46+
$this->setAttribute('timeout', array($new_tag), false);
47+
return $new_tag;
2948
}
3049

3150
public function getDefaultAttributes()
3251
{
3352
return [
34-
'waittime' => 10,
35-
'maxrepeat' => 3,
36-
'type' => 'parallel',
37-
'dtmftimeout' => 3,
53+
'waittime' => 10,
54+
'maxrepeat' => 3,
55+
'type' => 'parallel',
56+
'dtmftimeout' => 3,
3857
'dtmftdefaultkey' => ''
3958
];
4059
}

src/Voice/Voice.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
class Voice
88
{
99
protected $name;
10-
protected $append = [];
10+
protected $append = [];
1111
protected $attributes = [];
12-
protected $nested = [];
12+
protected $nested = [];
1313

1414
/**
1515
* DialPlan Constructor
@@ -44,13 +44,13 @@ public function setAttribute($name, $value = null, $instance = false)
4444
if ($instance) {
4545
return $value;
4646
}
47-
47+
4848
return $this;
4949
}
50-
50+
5151
public function append($verb, $args = [])
5252
{
53-
$widget = 'Mobtexting\\Voice\\Tag\\'.ucfirst(strtolower($verb));
53+
$widget = 'Mobtexting\\Voice\\Tag\\' . ucfirst(strtolower($verb));
5454

5555
$widget = new $widget(...$args);
5656

@@ -94,7 +94,7 @@ public function toArray()
9494
$element = array();
9595
$attributes = $this->getDefaultAttributes();
9696

97-
$attributes = array_merge($attributes, $this->processAttribs($this->attributes));
97+
$attributes = array_replace($attributes, $this->processAttribs($this->attributes));
9898

9999
$element[$this->name] = $attributes;
100100

0 commit comments

Comments
 (0)