PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.11
Booking for Appointments and Events Calendar – Amelia v1.2.11
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 / Domain / Factory / Settings / SettingsFactory.php
ameliabooking / src / Domain / Factory / Settings Last commit date
SettingsFactory.php 2 years ago
SettingsFactory.php
122 lines
1 <?php
2 /**
3 * @copyright © TMS-Plugins. All rights reserved.
4 * @licence See LICENCE.md for license details.
5 */
6
7 namespace AmeliaBooking\Domain\Factory\Settings;
8
9 use AmeliaBooking\Domain\Entity\Settings\GeneralSettings;
10 use AmeliaBooking\Domain\Entity\Settings\GoogleMeetSettings;
11 use AmeliaBooking\Domain\Entity\Settings\LessonSpaceSettings;
12 use AmeliaBooking\Domain\Entity\Settings\PaymentSettings;
13 use AmeliaBooking\Domain\Entity\Settings\Settings;
14 use AmeliaBooking\Domain\Entity\Settings\ZoomSettings;
15 use AmeliaBooking\Domain\ValueObjects\Json;
16
17 /**
18 * Class SettingsFactory
19 *
20 * @package AmeliaBooking\Domain\Factory\Settings
21 */
22 class SettingsFactory
23 {
24 /**
25 * @param Json $entityJsonData
26 * @param array $globalSettings
27 *
28 * @return Settings
29 */
30 public static function create($entityJsonData, $globalSettings)
31 {
32 $entitySettings = new Settings();
33 $generalSettings = new GeneralSettings();
34 $zoomSettings = new ZoomSettings();
35 $paymentSettings = new PaymentSettings();
36 $lessonSpaceSetings = new LessonSpaceSettings();
37 $googleMeetSettings = new GoogleMeetSettings();
38
39 $data = $entityJsonData ? json_decode($entityJsonData->getValue(), true) : [];
40
41 $isOldEntitySettings = !isset($data['activation']['version']);
42
43 if (isset($data['general']['defaultAppointmentStatus'])) {
44 $generalSettings->setDefaultAppointmentStatus($data['general']['defaultAppointmentStatus']);
45 } else {
46 $generalSettings->setDefaultAppointmentStatus($globalSettings['general']['defaultAppointmentStatus']);
47 }
48
49 if (isset($data['general']['minimumTimeRequirementPriorToBooking'])) {
50 $generalSettings->setMinimumTimeRequirementPriorToBooking(
51 $data['general']['minimumTimeRequirementPriorToBooking']
52 );
53 } else {
54 $generalSettings->setMinimumTimeRequirementPriorToBooking(
55 $globalSettings['general']['minimumTimeRequirementPriorToBooking']
56 );
57 }
58
59 if (isset($data['general']['minimumTimeRequirementPriorToCanceling'])) {
60 $generalSettings->setMinimumTimeRequirementPriorToCanceling(
61 $data['general']['minimumTimeRequirementPriorToCanceling']
62 );
63 } else {
64 $generalSettings->setMinimumTimeRequirementPriorToCanceling(
65 $globalSettings['general']['minimumTimeRequirementPriorToCanceling']
66 );
67 }
68
69 if (isset($data['general']['minimumTimeRequirementPriorToRescheduling'])) {
70 $generalSettings->setMinimumTimeRequirementPriorToRescheduling(
71 $data['general']['minimumTimeRequirementPriorToRescheduling']
72 );
73 } else {
74 $generalSettings->setMinimumTimeRequirementPriorToRescheduling(
75 $globalSettings['general']['minimumTimeRequirementPriorToRescheduling']
76 );
77 }
78
79 if ($isOldEntitySettings && !isset($globalSettings['general']['minimumTimeRequirementPriorToCanceling'])) {
80 $generalSettings->setMinimumTimeRequirementPriorToRescheduling(
81 $generalSettings->getMinimumTimeRequirementPriorToCanceling()
82 );
83 }
84
85 if (!empty($data['general']['numberOfDaysAvailableForBooking'])) {
86 $generalSettings->setNumberOfDaysAvailableForBooking(
87 $data['general']['numberOfDaysAvailableForBooking']
88 );
89 } else {
90 $generalSettings->setNumberOfDaysAvailableForBooking(
91 $globalSettings['general']['numberOfDaysAvailableForBooking']
92 );
93 }
94
95 if (isset($data['zoom']['enabled'])) {
96 $zoomSettings->setEnabled($data['zoom']['enabled']);
97 } else {
98 $zoomSettings->setEnabled($globalSettings['zoom']['enabled']);
99 }
100
101 if (isset($data['lessonSpace']['enabled'])) {
102 $lessonSpaceSetings->setEnabled($data['lessonSpace']['enabled']);
103 } else {
104 $lessonSpaceSetings->setEnabled($globalSettings['lessonSpace']['enabled']);
105 }
106
107 if (isset($data['googleMeet']['enabled'])) {
108 $googleMeetSettings->setEnabled($data['googleMeet']['enabled']);
109 } else {
110 $googleMeetSettings->setEnabled($globalSettings['googleCalendar']['enableGoogleMeet']);
111 }
112
113
114 $entitySettings->setGeneralSettings($generalSettings);
115 $entitySettings->setZoomSettings($zoomSettings);
116 $entitySettings->setLessonSpaceSettings($lessonSpaceSetings);
117 $entitySettings->setGoogleMeetSettings($googleMeetSettings);
118
119 return $entitySettings;
120 }
121 }
122