PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.6
Booking for Appointments and Events Calendar – Amelia v2.4.6
2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Application / Commands / Booking / Appointment / DeleteBookingCommandHandler.php
ameliabooking / src / Application / Commands / Booking / Appointment Last commit date
AddAppointmentCommand.php 1 year ago AddAppointmentCommandHandler.php 6 days ago AddBookingCommand.php 1 year ago AddBookingCommandHandler.php 6 days ago ApproveBookingRemotelyCommand.php 1 year ago ApproveBookingRemotelyCommandHandler.php 3 months ago CancelBookingCommand.php 1 year ago CancelBookingCommandHandler.php 6 days ago CancelBookingRemotelyCommand.php 1 year ago CancelBookingRemotelyCommandHandler.php 2 months ago DeleteAppointmentCommand.php 1 year ago DeleteAppointmentCommandHandler.php 1 year ago DeleteBookingCommand.php 1 year ago DeleteBookingCommandHandler.php 11 months ago DeleteBookingRemotelyCommand.php 11 months ago DeleteBookingRemotelyCommandHandler.php 7 months ago GetAppointmentBookingsCommand.php 7 months ago GetAppointmentBookingsCommandHandler.php 6 days ago GetAppointmentCommand.php 7 years ago GetAppointmentCommandHandler.php 6 days ago GetAppointmentsCommand.php 1 year ago GetAppointmentsCommandHandler.php 6 days ago GetIcsCommand.php 7 months ago GetIcsCommandHandler.php 4 years ago GetTimeSlotsCommand.php 1 year ago GetTimeSlotsCommandHandler.php 3 weeks ago ReassignBookingCommand.php 1 year ago ReassignBookingCommandHandler.php 6 days ago RejectBookingRemotelyCommand.php 1 year ago RejectBookingRemotelyCommandHandler.php 6 months ago SuccessfulBookingCommand.php 1 year ago SuccessfulBookingCommandHandler.php 1 year ago UpdateAppointmentCommand.php 1 year ago UpdateAppointmentCommandHandler.php 6 days ago UpdateAppointmentNoteCommand.php 4 months ago UpdateAppointmentNoteCommandHandler.php 6 days ago UpdateAppointmentStatusCommand.php 1 year ago UpdateAppointmentStatusCommandHandler.php 6 days ago UpdateAppointmentTimeCommand.php 1 year ago UpdateAppointmentTimeCommandHandler.php 6 days ago UpdateBookingStatusCommand.php 1 year ago UpdateBookingStatusCommandHandler.php 6 months ago
DeleteBookingCommandHandler.php
61 lines
1 <?php
2
3 namespace AmeliaBooking\Application\Commands\Booking\Appointment;
4
5 use AmeliaBooking\Application\Commands\CommandHandler;
6 use AmeliaBooking\Application\Commands\CommandResult;
7 use AmeliaBooking\Application\Common\Exceptions\AccessDeniedException;
8 use AmeliaBooking\Application\Services\Reservation\AppointmentReservationService;
9 use AmeliaBooking\Domain\Entity\Entities;
10 use AmeliaBooking\Infrastructure\Common\Exceptions\NotFoundException;
11 use AmeliaBooking\Infrastructure\Common\Exceptions\QueryExecutionException;
12 use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException;
13 use Slim\Exception\ContainerValueNotFoundException;
14 use Interop\Container\Exception\ContainerException;
15
16 /**
17 * Class DeleteBookingCommandHandler
18 *
19 * @package AmeliaBooking\Application\Commands\Booking\Appointment
20 */
21 class DeleteBookingCommandHandler extends CommandHandler
22 {
23 /**
24 * @param DeleteBookingCommand $command
25 *
26 * @return CommandResult
27 * @throws InvalidArgumentException
28 * @throws ContainerValueNotFoundException
29 * @throws AccessDeniedException
30 * @throws QueryExecutionException
31 * @throws ContainerException
32 * @throws NotFoundException
33 */
34 public function handle(DeleteBookingCommand $command)
35 {
36 if (!$command->getPermissionService()->currentUserCanDelete(Entities::APPOINTMENTS)) {
37 throw new AccessDeniedException('You are not allowed to delete appointment');
38 }
39
40 $result = new CommandResult();
41
42 /** @var AppointmentReservationService $reservationService */
43 $reservationService = $this->container->get('application.reservation.service')->get(Entities::APPOINTMENT);
44
45 try {
46 $resultData = $reservationService->deleteBooking($command->getArg('id'));
47 } catch (\Exception $e) {
48 $result->setResult(CommandResult::RESULT_ERROR);
49 $result->setMessage('Could not delete booking');
50
51 return $result;
52 }
53
54 $result->setResult(CommandResult::RESULT_SUCCESS);
55 $result->setMessage('Successfully deleted booking');
56 $result->setData($resultData);
57
58 return $result;
59 }
60 }
61