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 / Controller / Booking / Appointment / GetTimeSlotsController.php
ameliabooking / src / Application / Controller / Booking / Appointment Last commit date
AddAppointmentController.php 2 months ago AddBookingController.php 2 months ago ApproveBookingRemotelyController.php 2 months ago CancelBookingController.php 2 months ago CancelBookingRemotelyController.php 2 months ago DeleteAppointmentController.php 2 months ago DeleteBookingController.php 2 months ago DeleteBookingRemotelyController.php 2 months ago GetAppointmentBookingsController.php 2 months ago GetAppointmentController.php 2 months ago GetAppointmentsController.php 2 months ago GetIcsController.php 2 months ago GetTimeSlotsController.php 2 months ago ReassignBookingController.php 2 months ago RejectBookingRemotelyController.php 2 months ago SuccessfulBookingController.php 2 months ago UpdateAppointmentController.php 2 months ago UpdateAppointmentNoteController.php 2 months ago UpdateAppointmentStatusController.php 2 months ago UpdateAppointmentTimeController.php 2 months ago UpdateBookingStatusController.php 2 months ago
GetTimeSlotsController.php
108 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 AmeliaVendor\Psr\Http\Message\ServerRequestInterface as 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 'structured',
42 ];
43
44 /**
45 * Instantiates the Get Time Slots command to hand it over to the Command Handler
46 *
47 * @param Request $request
48 * @param $args
49 *
50 * @return mixed
51 * @throws \RuntimeException
52 */
53 protected function instantiateCommand(Request $request, $args)
54 {
55 $command = new GetTimeSlotsCommand($args);
56
57 $params = (array)$request->getQueryParams();
58
59 if (!empty($params['extras'])) {
60 if (($arrayExtras = json_decode($params['extras'], true)) !== null) {
61 $params['extras'] = $arrayExtras;
62 } else {
63 $arrayExtras = [];
64
65 foreach (explode(',', $params['extras']) as $item) {
66 $extrasData = explode('-', $item);
67
68 $arrayExtras[] = ['id' => $extrasData[0], 'quantity' => $extrasData[1]];
69 }
70
71 $params['extras'] = $arrayExtras;
72 }
73 }
74
75 $this->setArrayParams($params);
76
77 $command->setField('serviceId', (int)self::getParam($request, 'serviceId', 0));
78 $command->setField('locationId', (int)self::getParam($request, 'locationId', 0));
79 $command->setField('locationIds', !empty($params['locationIds']) ? $params['locationIds'] : []);
80 $command->setField('serviceDuration', (int)self::getParam($request, 'serviceDuration', 0));
81 $command->setField('weekDays', (array)self::getParam($request, 'weekDays', [1, 2, 3, 4, 5, 6, 7]));
82 $command->setField('startDateTime', (string)self::getParam($request, 'startDateTime', ''));
83 $command->setField('endDateTime', (string)self::getParam($request, 'endDateTime', ''));
84 $command->setField('providerIds', !empty($params['providerIds']) ? $params['providerIds'] : []);
85 $command->setField('extras', !empty($params['extras']) ? $params['extras'] : []);
86 $command->setField('excludeAppointmentId', (int)self::getParam($request, 'excludeAppointmentId', []));
87 $command->setField('persons', (int)self::getParam($request, 'persons', 1));
88 $command->setField('group', (int)self::getParam($request, 'group', 0));
89 $command->setField('page', (string)self::getParam($request, 'page', ''));
90 $command->setField('monthsLoad', (int)self::getParam($request, 'monthsLoad', 0));
91 $command->setField('queryTimeZone', (string)self::getParam($request, 'queryTimeZone', ''));
92 $command->setField('timeZone', (string)self::getParam($request, 'timeZone', ''));
93
94 $command->setField('allowAdminBookAtAnyTime', self::getParam($request, 'allowAdminBookAtAnyTime'));
95 $command->setField('allowBookingIfPending', self::getParam($request, 'allowBookingIfPending'));
96 $command->setField('allowBookingIfNotMin', self::getParam($request, 'allowBookingIfNotMin'));
97 $command->setField('timeSlotLength', self::getParam($request, 'timeSlotLength'));
98 $command->setField('serviceDurationAsSlot', self::getParam($request, 'serviceDurationAsSlot'));
99 $command->setField('bufferTimeInSlot', self::getParam($request, 'bufferTimeInSlot'));
100 $command->setField('structured', self::getParam($request, 'structured'));
101
102 $requestBody = $request->getParsedBody();
103 $this->setCommandFields($command, $requestBody);
104
105 return $command;
106 }
107 }
108