PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / trunk
Booking for Appointments and Events Calendar – Amelia vtrunk
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 / Infrastructure / Licence / ApplicationService.php
ameliabooking / src / Infrastructure / Licence Last commit date
Lite 2 months ago ApplicationService.php 1 month ago DataModifier.php 1 month ago DomainService.php 1 month ago EventListener.php 1 month ago InfrastructureService.php 1 month ago Licence.php 2 weeks ago LicenceConstants.php 6 months ago
ApplicationService.php
66 lines
1 <?php
2
3 namespace AmeliaBooking\Infrastructure\Licence;
4
5 use AmeliaBooking\Domain\Services\Settings\SettingsService;
6 use AmeliaBooking\Infrastructure\WP\SettingsService\SettingsStorage;
7
8 /**
9 * Class ApplicationService
10 *
11 * @package AmeliaBooking\Infrastructure\Licence
12 */
13 class ApplicationService extends Lite\ApplicationService
14 {
15 /**
16 * Map of license names to their corresponding class names
17 */
18 private static $licenseClassMap = [
19 LicenceConstants::LITE => 'AmeliaBooking\Infrastructure\Licence\Lite\ApplicationService',
20 LicenceConstants::STARTER => 'AmeliaBooking\Infrastructure\Licence\Lite\ApplicationService',
21 LicenceConstants::BASIC => 'AmeliaBooking\Infrastructure\Licence\Lite\ApplicationService',
22 LicenceConstants::PRO => 'AmeliaBooking\Infrastructure\Licence\Lite\ApplicationService',
23 LicenceConstants::DEVELOPER => 'AmeliaBooking\Infrastructure\Licence\Lite\ApplicationService',
24 ];
25
26 /**
27 * Get the appropriate license class based on settings (only in development mode)
28 *
29 * @return string The fully qualified class name of the license
30 */
31 private static function getLicenseClass()
32 {
33 // In production, always use the parent class (Lite)
34 if (!AMELIA_DEV) {
35 return 'AmeliaBooking\Infrastructure\Licence\Lite\ApplicationService';
36 }
37
38 // In development, get the license from settings
39 $settingsService = new SettingsService(new SettingsStorage());
40 $currentLicense = $settingsService->getSetting('activation', 'licence');
41 $currentLicense = !empty($currentLicense) ? $currentLicense : LicenceConstants::DEVELOPER;
42
43 // Return the appropriate license class
44 return self::$licenseClassMap[$currentLicense] ?? 'AmeliaBooking\Infrastructure\Licence\Lite\ApplicationService';
45 }
46
47 /**
48 * Delegate static method calls to the appropriate license class in development mode
49 *
50 * @param string $method
51 * @param array $arguments
52 * @return mixed
53 */
54 public static function __callStatic($method, $arguments)
55 {
56 // In production, use normal inheritance (class extends were changed by build scripts)
57 if (!AMELIA_DEV) {
58 return call_user_func_array(['parent', $method], $arguments);
59 }
60
61 // In development, dynamically load the appropriate license class
62 $licenseClass = self::getLicenseClass();
63 return call_user_func_array([$licenseClass, $method], $arguments);
64 }
65 }
66