|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @author Markus Tacker <[email protected]> |
|
5
|
|
|
* @copyright 2013-2016 Verein zur Förderung der Netzkultur im Rhein-Main-Gebiet e.V. | http://netzkultur-rheinmain.de/ |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace BCRM\BackendBundle\Service; |
|
9
|
|
|
|
|
10
|
|
|
use BCRM\BackendBundle\Event\Concierge\CheckedInEvent; |
|
11
|
|
|
use BCRM\BackendBundle\Service\Concierge\CheckinCommand; |
|
12
|
|
|
use BCRM\BackendBundle\Service\Concierge\PayRegistrationConciergeCommand; |
|
13
|
|
|
use BCRM\BackendBundle\Entity\PaymentRepository; |
|
14
|
|
|
use BCRM\BackendBundle\Entity\Event\RegistrationRepository; |
|
15
|
|
|
use Endroid\QrCode\QrCode; |
|
16
|
|
|
use LiteCQRS\Bus\CommandBus; |
|
17
|
|
|
use LiteCQRS\Bus\EventMessageBus; |
|
18
|
|
|
use LiteCQRS\Plugin\CRUD\Model\Commands\UpdateResourceCommand; |
|
19
|
|
|
use LiteCQRS\Plugin\CRUD\Model\Commands\CreateResourceCommand; |
|
20
|
|
|
use Symfony\Component\Routing\RouterInterface; |
|
21
|
|
|
use LiteCQRS\Plugin\CRUD\Model\Events\ResourceCreatedEvent; |
|
22
|
|
|
|
|
23
|
|
|
class Concierge |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @var \LiteCQRS\Bus\CommandBus |
|
27
|
|
|
*/ |
|
28
|
|
|
private $commandBus; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var \LiteCQRS\Bus\EventMessageBus |
|
32
|
|
|
*/ |
|
33
|
|
|
private $eventMessageBus; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @param CommandBus $commandBus |
|
37
|
|
|
* @param RouterInterface $router |
|
|
|
|
|
|
38
|
|
|
* @param PaymentRepository $paymentRepo |
|
39
|
|
|
* @param RegistrationRepository $registrationRepo |
|
40
|
|
|
*/ |
|
41
|
|
|
public function __construct( |
|
42
|
|
|
CommandBus $commandBus, |
|
43
|
|
|
EventMessageBus $eventMessageBus, |
|
44
|
|
|
PaymentRepository $paymentRepo, |
|
45
|
|
|
RegistrationRepository $registrationRepo |
|
46
|
|
|
) |
|
47
|
|
|
{ |
|
48
|
|
|
$this->commandBus = $commandBus; |
|
49
|
|
|
$this->eventMessageBus = $eventMessageBus; |
|
50
|
|
|
$this->paymentRepo = $paymentRepo; |
|
|
|
|
|
|
51
|
|
|
$this->registrationRepo = $registrationRepo; |
|
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function checkin(CheckinCommand $command) |
|
55
|
|
|
{ |
|
56
|
|
|
$updateCommand = new UpdateResourceCommand(); |
|
57
|
|
|
$updateCommand->class = '\BCRM\BackendBundle\Entity\Event\Ticket'; |
|
58
|
|
|
$updateCommand->id = $command->ticket->getId(); |
|
59
|
|
|
$updateCommand->data = array('checkedIn' => new \DateTime()); |
|
60
|
|
|
$this->commandBus->handle($updateCommand); |
|
61
|
|
|
|
|
62
|
|
|
$event = new CheckedInEvent(); |
|
63
|
|
|
$event->ticket = $command->ticket; |
|
64
|
|
|
$this->eventMessageBus->publish($event); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function payRegistrationConcierge(PayRegistrationConciergeCommand $command) |
|
68
|
|
|
{ |
|
69
|
|
|
$createCommand = new CreateResourceCommand(); |
|
70
|
|
|
$createCommand->class = '\BCRM\BackendBundle\Entity\Payment'; |
|
71
|
|
|
$createCommand->data = array( |
|
72
|
|
|
'txId' => $command->uuid, |
|
73
|
|
|
'payload' => [], |
|
74
|
|
|
'method' => 'concierge', |
|
75
|
|
|
'checked' => new \DateTime(), |
|
76
|
|
|
'verified' => '1' |
|
77
|
|
|
); |
|
78
|
|
|
$this->commandBus->handle($createCommand); |
|
79
|
|
|
|
|
80
|
|
|
$paymentOption = $this->paymentRepo->findByTxId($command->uuid); |
|
81
|
|
|
if ($paymentOption->isDefined()) { |
|
|
|
|
|
|
82
|
|
|
|
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function onResourceCreated(ResourceCreatedEvent $event) |
|
87
|
|
|
{ |
|
88
|
|
|
if ($event->class !== 'BCRM\BackendBundle\Entity\Payment') { |
|
89
|
|
|
return; |
|
90
|
|
|
} |
|
91
|
|
|
$registrationOption = $this->registrationRepo->findByUuid($event->data['txId']); |
|
92
|
|
|
if ($registrationOption->isDefined()) { |
|
93
|
|
|
$payRegistrationCommand = new \BCRM\BackendBundle\Service\Payment\PayRegistrationCommand(); |
|
94
|
|
|
$payRegistrationCommand->registration = $registrationOption->get(); |
|
95
|
|
|
$payRegistrationCommand->payment = $this->paymentRepo->findByTxId($event->data['txId'])->get(); |
|
96
|
|
|
$this->commandBus->handle($payRegistrationCommand); |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.