VoiceCallAuditLogResolver.php
1.62 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
<?php
namespace NexmoBundle\Event\Logger;
use AppBundle\Entity\User;
use AppBundle\Event\VoiceCallEvents;
use Chromedia\AuditLogBundle\Resolver\EventResolverInterface;
use NexmoBundle\Event\Logger\Command\InboundVoiceCallCommand;
use NexmoBundle\Event\Logger\Command\UpdateVoiceCallStatusCommand;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
class VoiceCallAuditLogResolver implements EventResolverInterface
{
protected $commands;
/**
* @var TokenStorage
*/
protected $tokenStorage;
public function __construct()
{
$this->commands = [
VoiceCallEvents::COMPLETED_VOICE_CALL => UpdateVoiceCallStatusCommand::class,
VoiceCallEvents::FAILED_VOICE_CALL => UpdateVoiceCallStatusCommand::class,
VoiceCallEvents::STARTED_VOICE_CALL => UpdateVoiceCallStatusCommand::class,
VoiceCallEvents::INBOUND_CALL_ONGOING => InboundVoiceCallCommand::class,
VoiceCallEvents::INBOUND_CALL_COMPLETED => InboundVoiceCallCommand::class
];
}
public function setTokenStorage(TokenStorage $v)
{
$this->tokenStorage = $v;
}
/**
* @param Event $event
* @param string $eventName
* @return mixed
*/
public function getEventLogInfo(Event $event, $eventName)
{
if (!isset($this->commands[$eventName])) {
return;
}
$class = $this->commands[$eventName];
$command = new $class();
if ($command instanceof VoiceCallAuditLogCommand) {
return $command->resolve($event);
}
}
}