example.php
1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
use PAGI\Application\PAGIApplication;
use PAGI\Node\Node;
class MyPagiApplication extends PAGIApplication
{
protected $agi;
protected $asteriskLogger;
protected $channelVariables;
public function mainMenu()
{
return $this->agi->createNode('mainMenu')
->saySound('pp/30')
->sayDigits(123)
->sayNumber(321)
->sayDateTime(1, 'dmY')
->unInterruptablePrompts()
->maxAttemptsForInput(1)
->endInputWith(Node::DTMF_HASH)
->playOnNoInput('pp/6')
->expectExactly(1)
->playOnMaxValidInputAttempts('pp/5')
->maxTotalTimeForInput(50000)
->maxTimeBetweenDigits(3000)
->validateInputWith(
'option',
function(Node $node) {
return $node->getInput() < 6 && $node->getInput() > 0;
},
'pp/50'
)->executeOnValidInput(function (Node $node) {
$node->getClient()->playBusyTone();
$node->getClient()->streamFile('hi');
})
;
}
public function run()
{
$this->agi->answer();
$digits = '';
$this->mainMenu()->run();
}
public function init()
{
$this->logger->info('Init');
$this->agi = $this->getAgi();
$this->asteriskLogger = $this->agi->getAsteriskLogger();
$this->channelVariables = $this->agi->getChannelVariables();
$this->asteriskLogger->notice('Init');
}
public function signalHandler($signo)
{
$this->asteriskLogger->notice("Got signal: $signo");
$this->logger->info("Got signal: $signo");
exit(0);
}
public function errorHandler($type, $message, $file, $line)
{
$this->logger->error("$message at $file:$line");
}
public function shutdown()
{
$this->asteriskLogger->notice('Shutdown');
}
}