PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.0.2
Booking for Appointments and Events Calendar – Amelia v2.0.2
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 / Settings / GetSettingsCommandHandler.php
ameliabooking / src / Application / Commands / Settings Last commit date
FeaturesIntegrations 6 months ago GetSettingsCommand.php 1 year ago GetSettingsCommandHandler.php 6 months ago UpdateSettingsCategoriesCommand.php 6 months ago UpdateSettingsCategoriesCommandHandler.php 6 months ago UpdateSettingsCommand.php 1 year ago UpdateSettingsCommandHandler.php 6 months ago
GetSettingsCommandHandler.php
76 lines
1 <?php
2
3 namespace AmeliaBooking\Application\Commands\Settings;
4
5 use AmeliaBooking\Application\Commands\CommandHandler;
6 use AmeliaBooking\Application\Commands\CommandResult;
7 use AmeliaBooking\Application\Common\Exceptions\AccessDeniedException;
8 use AmeliaBooking\Domain\Entity\Entities;
9 use AmeliaBooking\Domain\Services\Settings\SettingsService;
10 use AmeliaBooking\Infrastructure\Services\Mailchimp\AbstractMailchimpService;
11 use Interop\Container\Exception\ContainerException;
12
13 /**
14 * Class GetSettingsCommandHandler
15 *
16 * @package AmeliaBooking\Application\Commands\Settings
17 */
18 class GetSettingsCommandHandler extends CommandHandler
19 {
20 /**
21 * @return CommandResult
22 * @throws ContainerException
23 * @throws AccessDeniedException
24 */
25 public function handle(GetSettingsCommand $command)
26 {
27 $result = new CommandResult();
28
29 if (!$command->getPermissionService()->currentUserCanRead(Entities::SETTINGS)) {
30 throw new AccessDeniedException('You are not allowed to read settings.');
31 }
32
33 /** @var SettingsService $settingsService */
34 $settingsService = $this->getContainer()->get('domain.settings.service');
35
36 $settings = $settingsService->getAllSettingsCategorized();
37
38 if ($settings['activation']['purchaseCodeStore'] !== '' && $settings['activation']['active']) {
39 $settings['activation']['purchaseCodeStore'] = null;
40 }
41
42 if (!empty($settings['payments']['square'])) {
43 $settings['payments']['square']['phpVersion'] = phpversion();
44 }
45
46 $mailchimpLists = [];
47 if ($settingsService->isFeatureEnabled('mailchimp') && !empty($settings['mailchimp']['accessToken'])) {
48 /** @var AbstractMailchimpService $mailchimpService */
49 $mailchimpService = $this->getContainer()->get('infrastructure.mailchimp.service');
50 $mailchimpLists = $mailchimpService->getLists();
51 if (!empty($mailchimpLists)) {
52 if (!$settings['mailchimp']['list']) {
53 $settings['mailchimp']['list'] = $mailchimpLists[0]['id'];
54 $settingsService->setCategorySettings('mailchimp', $settings['mailchimp']);
55 }
56 }
57 }
58
59 $result->setResult(CommandResult::RESULT_SUCCESS);
60 $result->setMessage('Successfully retrieved settings.');
61
62 $settings = apply_filters('amelia_get_settings_filter', $settings);
63
64 do_action('amelia_get_settings', $settings);
65
66 $result->setData(
67 [
68 'settings' => $settings,
69 'additionalData' => ['mailchimpLists' => $mailchimpLists]
70 ]
71 );
72
73 return $result;
74 }
75 }
76