@@ -13,42 +13,54 @@ 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 = [], $ isSequential = false )
2230 {
23- $ newTag = $ this ->append ($ verb , $ attribs );
24- if ($ isSequential ){
25- $ this ->attributes ['onfail ' ] = array_merge ($ this ->attributes ['onfail ' ], array ($ newTag ) );
26- }else {
27- $ this ->setAttribute ('onfail ' , array ($ newTag ), true );
28- }
29- return $ newTag ;
31+ $ new_tag = $ this ->append ($ verb , $ attribs );
32+ $ this ->setAttribute ('onfail ' , array ($ new_tag ), false );
33+ return $ new_tag ;
3034 }
3135
32- public function onTimeout ( $ verb , $ attribs = [], $ isSequential = false )
36+ public function onKeyPress ( $ key , $ verb , $ attribs = [])
3337 {
34- $ newTag = $ this ->append ($ verb , $ attribs );
35- if ($ isSequential ){
36- $ this ->attributes ['timeout ' ] = array_merge ($ this ->attributes ['timeout ' ], array ($ newTag ) );
37- }else {
38- $ this ->setAttribute ('timeout ' , array ($ newTag ), true );
39- }
38+ $ new_tag = $ this ->append ($ verb , $ attribs );
39+ $ this ->setAttribute ($ key , array ($ new_tag ), false );
40+ return $ new_tag ;
41+ }
42+ public function onWrongKey ($ verb , $ attribs = [])
43+ {
44+ $ new_tag = $ this ->append ($ verb , $ attribs );
45+ $ this ->setAttribute ('wrongkey ' , array ($ new_tag ), false );
46+ return $ new_tag ;
47+ }
4048
41- return $ newTag ;
49+ public function onTimeout ($ verb , $ attribs = [], $ isSequential = false )
50+ {
51+ $ new_tag = $ this ->append ($ verb , $ attribs );
52+ $ this ->setAttribute ('timeout ' , array ($ new_tag ), false );
53+ return $ new_tag ;
4254 }
4355
4456 public function getDefaultAttributes ()
4557 {
4658 return [
47- 'waittime ' => 10 ,
48- 'maxrepeat ' => 3 ,
49- 'type ' => 'parallel ' ,
50- 'dtmftimeout ' => 3 ,
51- 'dtmftdefaultkey ' => ''
59+ 'waittime ' => 10 ,
60+ 'maxrepeat ' => 3 ,
61+ 'type ' => 'parallel ' ,
62+ 'dtmftimeout ' => 3 ,
63+ 'dtmfdefaultkey ' => ''
5264 ];
5365 }
5466}
0 commit comments