Tag
1 month ago
AddEventController.php
1 month ago
DeleteEventBookingController.php
1 month ago
DeleteEventController.php
1 month ago
DeleteEventsController.php
1 month ago
GetCalendarEventsController.php
1 month ago
GetEventBookingController.php
1 month ago
GetEventBookingsController.php
1 month ago
GetEventController.php
1 month ago
GetEventsController.php
4 days ago
UpdateEventBookingController.php
1 month ago
UpdateEventController.php
1 month ago
UpdateEventStatusController.php
1 month ago
UpdateEventVisibilityController.php
1 month ago
DeleteEventBookingController.php
51 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Application\Controller\Booking\Event; |
| 4 | |
| 5 | use AmeliaBooking\Application\Commands\Booking\Event\DeleteEventBookingCommand; |
| 6 | use AmeliaBooking\Application\Commands\CommandResult; |
| 7 | use AmeliaBooking\Application\Controller\Controller; |
| 8 | use AmeliaBooking\Domain\Events\DomainEventBus; |
| 9 | use RuntimeException; |
| 10 | use AmeliaVendor\Psr\Http\Message\ServerRequestInterface as Request; |
| 11 | |
| 12 | /** |
| 13 | * Class DeleteEventBookingController |
| 14 | * |
| 15 | * @package AmeliaBooking\Application\Controller\Booking\Event |
| 16 | */ |
| 17 | class DeleteEventBookingController extends Controller |
| 18 | { |
| 19 | /** |
| 20 | * Instantiates the Delete Event Booking command to hand it over to the Command Handler |
| 21 | * |
| 22 | * @param Request $request |
| 23 | * @param $args |
| 24 | * |
| 25 | * @return DeleteEventBookingCommand |
| 26 | * @throws RuntimeException |
| 27 | */ |
| 28 | protected function instantiateCommand(Request $request, $args) |
| 29 | { |
| 30 | $command = new DeleteEventBookingCommand($args); |
| 31 | |
| 32 | $requestBody = $request->getParsedBody(); |
| 33 | $this->setCommandFields($command, $requestBody); |
| 34 | |
| 35 | $command->setToken($request); |
| 36 | |
| 37 | return $command; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * @param DomainEventBus $eventBus |
| 42 | * @param CommandResult $result |
| 43 | * |
| 44 | * @return void |
| 45 | */ |
| 46 | protected function emitSuccessEvent(DomainEventBus $eventBus, CommandResult $result) |
| 47 | { |
| 48 | $eventBus->emit('BookingCanceled', $result); |
| 49 | } |
| 50 | } |
| 51 |