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\Command; |
9
|
|
|
|
10
|
|
|
use BCRM\BackendBundle\Entity\Event\Event; |
11
|
|
|
use BCRM\BackendBundle\Entity\Event\Registration; |
12
|
|
|
use BCRM\BackendBundle\Entity\Event\Ticket; |
13
|
|
|
use BCRM\BackendBundle\Exception\CommandException; |
14
|
|
|
use BCRM\BackendBundle\Service\Event\CreateTicketCommand; |
15
|
|
|
use BCRM\BackendBundle\Service\Event\UnregisterTicketCommand; |
16
|
|
|
use Doctrine\Common\Util\Debug; |
17
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
18
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
19
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
20
|
|
|
|
21
|
|
|
class ProcessUnregistrationsCommand extends ContainerAwareCommand |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var OutputInterface |
25
|
|
|
*/ |
26
|
|
|
private $output; |
27
|
|
|
|
28
|
|
|
protected function configure() |
29
|
|
|
{ |
30
|
|
|
$this |
31
|
|
|
->setName('bcrm:tickets:process-unregistrations') |
32
|
|
|
->setDescription('Remove unregistered tickets'); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
36
|
|
|
{ |
37
|
|
|
$this->output = $output; |
38
|
|
|
/** @var \BCRM\BackendBundle\Entity\Event\UnregistrationRepository $unRepo */ |
39
|
|
|
/** @var \BCRM\BackendBundle\Entity\Event\EventRepository $eventRepo */ |
40
|
|
|
$eventRepo = $this->getContainer()->get('bcrm.backend.repo.event'); |
41
|
|
|
$unRepo = $this->getContainer()->get('bcrm.backend.repo.unregistration'); |
42
|
|
|
$event = $eventRepo->getNextEvent()->getOrThrow(new CommandException('No event.')); |
43
|
|
|
$commandBus = $this->getContainer()->get('command_bus'); |
44
|
|
|
foreach ($unRepo->getUnprocessedUnregistrations($event) as $unregistration) { |
45
|
|
|
if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) { |
46
|
|
|
$this->output->writeln(sprintf('Processing unregistration %s', $unregistration)); |
47
|
|
|
} |
48
|
|
|
$command = new UnregisterTicketCommand(); |
49
|
|
|
$command->unregistration = $unregistration; |
50
|
|
|
$command->event = $event; |
51
|
|
|
$commandBus->handle($command); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
} |
56
|
|
|
|