|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ConferenceTools\Checkin\Cli\Command; |
|
4
|
|
|
|
|
5
|
|
|
use Carnage\Cqrs\Event\Projection\PostRebuildInterface; |
|
6
|
|
|
use Carnage\Cqrs\Event\Projection\PreRebuildInterface; |
|
7
|
|
|
use Carnage\Cqrs\Event\Projection\ResettableInterface; |
|
8
|
|
|
use Carnage\Cqrs\MessageHandler\MessageHandlerInterface; |
|
9
|
|
|
use Carnage\Cqrs\Persistence\EventStore\LoadEventsInterface; |
|
10
|
|
|
use ConferenceTools\Checkin\AntiCorruption\TicketMappingListener; |
|
11
|
|
|
use ConferenceTools\Checkin\Domain\ProcessManager\ImportPurchase; |
|
12
|
|
|
use Symfony\Component\Console\Command\Command; |
|
13
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
14
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
15
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
16
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
17
|
|
|
use Zend\ServiceManager\Config; |
|
18
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
|
19
|
|
|
|
|
20
|
|
|
class ImportExistingTickets extends Command |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @var array |
|
24
|
|
|
*/ |
|
25
|
|
|
private $eventTypes; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var TicketMappingListener |
|
29
|
|
|
*/ |
|
30
|
|
|
private $ticketMappingListener; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var LoadEventsInterface |
|
34
|
|
|
*/ |
|
35
|
|
|
private $eventStore; |
|
36
|
|
|
|
|
37
|
|
|
public static function build( |
|
38
|
|
|
array $subscriptions, |
|
39
|
|
|
TicketMappingListener $ticketMappingListener, |
|
40
|
|
|
LoadEventsInterface $eventStore |
|
41
|
|
|
) { |
|
42
|
|
|
$instance = new static(); |
|
43
|
|
|
|
|
44
|
|
|
foreach ($subscriptions as $event => $listeners) { |
|
45
|
|
|
foreach ((array) $listeners as $listener) { |
|
46
|
|
|
if ($listener === TicketMappingListener::class) { |
|
47
|
|
|
$instance->eventTypes[] = $event; |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
$instance->eventStore = $eventStore; |
|
53
|
|
|
$instance->ticketMappingListener = $ticketMappingListener; |
|
54
|
|
|
|
|
55
|
|
|
return $instance; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
protected function configure() |
|
59
|
|
|
{ |
|
60
|
|
|
$this->setName('checkin:import-existing-tickets') |
|
61
|
|
|
->setDescription('Imports existing tickets from the event store.') |
|
62
|
|
|
->setDefinition([ |
|
63
|
|
|
]); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
67
|
|
|
{ |
|
68
|
|
|
$events = $this->eventStore->loadEventsByTypes(...$this->eventTypes); |
|
69
|
|
|
|
|
70
|
|
|
foreach ($events as $event) { |
|
71
|
|
|
$this->ticketMappingListener->handleDomainMessage($event); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|