PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.20
Booking for Appointments and Events Calendar – Amelia v1.2.20
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 / Controller / Booking / Appointment / GetTimeSlotsController.php
ameliabooking / src / Application / Controller / Booking / Appointment Last commit date
AddAppointmentController.php 2 years ago AddBookingController.php 2 years ago ApproveBookingRemotelyController.php 2 years ago CancelBookingController.php 6 years ago CancelBookingRemotelyController.php 2 years ago DeleteAppointmentController.php 7 years ago DeleteBookingController.php 4 years ago GetAppointmentController.php 4 years ago GetAppointmentsController.php 1 year ago GetIcsController.php 4 years ago GetPackageAppointmentsController.php 1 year ago GetTimeSlotsController.php 1 year ago ReassignBookingController.php 1 year ago RejectBookingRemotelyController.php 2 years ago SuccessfulBookingController.php 1 year ago UpdateAppointmentController.php 2 years ago UpdateAppointmentStatusController.php 4 years ago UpdateAppointmentTimeController.php 1 year ago UpdateBookingStatusController.php 1 year ago
GetTimeSlotsController.php
105 lines
1 <?php
2
3 namespace AmeliaBooking\Application\Controller\Booking\Appointment;
4
5 use AmeliaBooking\Application\Commands\Booking\Appointment\GetTimeSlotsCommand;
6 use AmeliaBooking\Application\Controller\Controller;
7 use Slim\Http\Request;
8
9 /**
10 * Class GetTimeSlotsController
11 *
12 * @package AmeliaBooking\Application\Controller\Booking\Appointment
13 */
14 class GetTimeSlotsController extends Controller
15 {
16 /**
17 * Fields for calendar service that can be received from front-end
18 *
19 * @var array
20 */
21 protected $allowedFields = [
22 'serviceId',
23 'serviceDuration',
24 'weekDays',
25 'startDateTime',
26 'providerIds',
27 'extras',
28 'excludeAppointmentId',
29 'persons',
30 'group',
31 'page',
32 'monthsLoad',
33 'queryTimeZone',
34 'timeZone',
35 'allowAdminBookAtAnyTime',
36 'allowBookingIfPending',
37 'allowBookingIfNotMin',
38 'timeSlotLength',
39 'serviceDurationAsSlot',
40 'bufferTimeInSlot'
41 ];
42
43 /**
44 * Instantiates the Get Time Slots command to hand it over to the Command Handler
45 *
46 * @param Request $request
47 * @param $args
48 *
49 * @return mixed
50 * @throws \RuntimeException
51 */
52 protected function instantiateCommand(Request $request, $args)
53 {
54 $command = new GetTimeSlotsCommand($args);
55
56 $params = (array)$request->getQueryParams();
57
58 if (!empty($params['extras'])) {
59 if (($arrayExtras = json_decode($params['extras'], true)) !== null) {
60 $params['extras'] = $arrayExtras;
61 } else {
62 $arrayExtras = [];
63
64 foreach (explode(',', $params['extras']) as $item) {
65 $extrasData = explode('-', $item);
66
67 $arrayExtras[] = ['id' => $extrasData[0], 'quantity' => $extrasData[1]];
68 }
69
70 $params['extras'] = $arrayExtras;
71 }
72 }
73
74 $this->setArrayParams($params);
75
76 $command->setField('serviceId', (int)$request->getQueryParam('serviceId', 0));
77 $command->setField('locationId', (int)$request->getQueryParam('locationId', 0));
78 $command->setField('serviceDuration', (int)$request->getQueryParam('serviceDuration', 0));
79 $command->setField('weekDays', (array)$request->getQueryParam('weekDays', [1, 2, 3, 4, 5, 6, 7]));
80 $command->setField('startDateTime', (string)$request->getQueryParam('startDateTime', ''));
81 $command->setField('endDateTime', (string)$request->getQueryParam('endDateTime', ''));
82 $command->setField('providerIds', !empty($params['providerIds']) ? $params['providerIds'] : []);
83 $command->setField('extras', !empty($params['extras']) ? $params['extras'] : []);
84 $command->setField('excludeAppointmentId', (int)$request->getQueryParam('excludeAppointmentId', []));
85 $command->setField('persons', (int)$request->getQueryParam('persons', 1));
86 $command->setField('group', (int)$request->getQueryParam('group', 0));
87 $command->setField('page', (string)$request->getQueryParam('page', ''));
88 $command->setField('monthsLoad', (int)$request->getQueryParam('monthsLoad', 0));
89 $command->setField('queryTimeZone', (string)$request->getQueryParam('queryTimeZone', ''));
90 $command->setField('timeZone', (string)$request->getQueryParam('timeZone', ''));
91
92 $command->setField('allowAdminBookAtAnyTime', $request->getQueryParam('allowAdminBookAtAnyTime'));
93 $command->setField('allowBookingIfPending', $request->getQueryParam('allowBookingIfPending'));
94 $command->setField('allowBookingIfNotMin', $request->getQueryParam('allowBookingIfNotMin'));
95 $command->setField('timeSlotLength', $request->getQueryParam('timeSlotLength'));
96 $command->setField('serviceDurationAsSlot', $request->getQueryParam('serviceDurationAsSlot'));
97 $command->setField('bufferTimeInSlot', $request->getQueryParam('bufferTimeInSlot'));
98
99 $requestBody = $request->getParsedBody();
100 $this->setCommandFields($command, $requestBody);
101
102 return $command;
103 }
104 }
105