ameliabooking
/
src
/
Application
/
Commands
/
Booking
/
Event
/
GetEventDeleteEffectCommandHandler.php
AddEventCommand.php
7 years ago
AddEventCommandHandler.php
2 years ago
DeleteEventBookingCommand.php
7 years ago
DeleteEventBookingCommandHandler.php
1 year ago
DeleteEventCommand.php
7 years ago
DeleteEventCommandHandler.php
2 years ago
GetCalendarEventsCommand.php
4 years ago
GetCalendarEventsCommandHandler.php
1 year ago
GetEventBookingsCommand.php
1 year ago
GetEventBookingsCommandHandler.php
1 year ago
GetEventCommand.php
7 years ago
GetEventCommandHandler.php
1 year ago
GetEventDeleteEffectCommand.php
7 years ago
GetEventDeleteEffectCommandHandler.php
2 years ago
GetEventsCommand.php
7 years ago
GetEventsCommandHandler.php
1 year ago
UpdateEventBookingCommand.php
7 years ago
UpdateEventBookingCommandHandler.php
1 year ago
UpdateEventCommand.php
7 years ago
UpdateEventCommandHandler.php
1 year ago
UpdateEventStatusCommand.php
7 years ago
UpdateEventStatusCommandHandler.php
2 years ago
GetEventDeleteEffectCommandHandler.php
57 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Application\Commands\Booking\Event; |
| 4 | |
| 5 | use AmeliaBooking\Application\Common\Exceptions\AccessDeniedException; |
| 6 | use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; |
| 7 | use AmeliaBooking\Domain\Entity\Booking\Event\Event; |
| 8 | use AmeliaBooking\Domain\Entity\Entities; |
| 9 | use AmeliaBooking\Application\Commands\CommandResult; |
| 10 | use AmeliaBooking\Application\Commands\CommandHandler; |
| 11 | use AmeliaBooking\Domain\ValueObjects\String\BookingStatus; |
| 12 | use AmeliaBooking\Infrastructure\Common\Exceptions\QueryExecutionException; |
| 13 | use AmeliaBooking\Infrastructure\Repository\Booking\Event\EventRepository; |
| 14 | use AmeliaBooking\Infrastructure\WP\Translations\BackendStrings; |
| 15 | |
| 16 | /** |
| 17 | * Class GetEventDeleteEffectCommandHandler |
| 18 | * |
| 19 | * @package AmeliaBooking\Application\Commands\Booking\Event |
| 20 | */ |
| 21 | class GetEventDeleteEffectCommandHandler extends CommandHandler |
| 22 | { |
| 23 | /** |
| 24 | * @param GetEventDeleteEffectCommand $command |
| 25 | * |
| 26 | * @return CommandResult |
| 27 | * @throws \Slim\Exception\ContainerValueNotFoundException |
| 28 | * @throws AccessDeniedException |
| 29 | * @throws InvalidArgumentException |
| 30 | * @throws QueryExecutionException |
| 31 | * @throws \Interop\Container\Exception\ContainerException |
| 32 | */ |
| 33 | public function handle(GetEventDeleteEffectCommand $command) |
| 34 | { |
| 35 | if (!$command->getPermissionService()->currentUserCanWrite(Entities::EVENTS)) { |
| 36 | throw new AccessDeniedException('You are not allowed to write events'); |
| 37 | } |
| 38 | |
| 39 | $result = new CommandResult(); |
| 40 | |
| 41 | /** @var EventRepository $eventRepository */ |
| 42 | $eventRepository = $this->container->get('domain.booking.event.repository'); |
| 43 | |
| 44 | /** @var Event $event */ |
| 45 | $event = $eventRepository->getById((int)$command->getArg('id')); |
| 46 | |
| 47 | $result->setResult(CommandResult::RESULT_SUCCESS); |
| 48 | $result->setMessage('Successfully retrieved message.'); |
| 49 | $result->setData([ |
| 50 | 'valid' => $event->getStatus()->getValue() === BookingStatus::REJECTED, |
| 51 | 'message' => $event->getStatus()->getValue() === BookingStatus::REJECTED ? '' : BackendStrings::getEventStrings()['event_cancel_before_delete'] |
| 52 | ]); |
| 53 | |
| 54 | return $result; |
| 55 | } |
| 56 | } |
| 57 |