PluginProbe
JetBackup – Backup, Restore & Migrate / 3.1.21.3
JetBackup – Backup, Restore & Migrate v3.1.21.3
3.1.23.6 3.1.23.5 3.1.23.3 3.1.22.4 3.1.22.3 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.8.1 1.4.9 1.5.0 1.5.1 1.5.1.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.10 All 82 releases
backup / src / JetBackup / Settings / Integrations.php
Integrations.php
75 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace JetBackup\Settings;
4
5 use JetBackup\Exception\AjaxException;
6 use JetBackup\Exception\DBException;
7 use SleekDB\Exceptions\InvalidArgumentException;
8 use SleekDB\Exceptions\IOException;
9
10 if (!defined( '__JETBACKUP__')) die('Direct access is not allowed');
11
12 class Integrations extends Settings {
13
14 const SECTION = 'integrations';
15 const ELEMENTOR = 'Elementor';
16 const SUPERCACHE = 'Supercache';
17 const WOOCOMMERCE = 'Woocommerce';
18 const AUTOPTIMIZE = 'Autoptimize';
19 const W3TOTALCACHE = 'W3TotalCache';
20
21 const INTEGRATIONS = 'integrations';
22 const INTEGRATION_DEFAULTS = [
23 self::ELEMENTOR,
24 self::SUPERCACHE,
25 self::WOOCOMMERCE,
26 self::W3TOTALCACHE,
27 self::AUTOPTIMIZE,
28 ];
29 /**
30 * @throws DBException
31 * @throws IOException
32 * @throws InvalidArgumentException
33 */
34 public function __construct() {
35 parent::__construct(self::SECTION);
36 }
37
38 public function getInegrations(): array {
39 return $this->get(self::INTEGRATIONS, self::INTEGRATION_DEFAULTS);
40 }
41
42 public function setIntegrations(array $values) : void {
43 $this->set(self::INTEGRATIONS, $values);
44 }
45 /**
46 * @return bool[]
47 */
48 public function getDisplay():array {
49 return [self::INTEGRATIONS => $this->getInegrations()];
50 }
51
52 /**
53 * @return bool[]
54 */
55 public function getDisplayCLI():array {
56 return [self::INTEGRATIONS => $this->getInegrations()];
57 }
58
59 /**
60 * @return void
61 * @throws AjaxException
62 */
63 public function validateFields():void {
64
65 $changedFields = self::getChangedFields($this->getData(), (new Integrations())->getData());
66
67 if(in_array(self::INTEGRATIONS, $changedFields)) {
68 $missing = array_diff($this->getInegrations(), self::INTEGRATION_DEFAULTS);
69
70 if (!empty($missing)) {
71 throw new AjaxException("The following integrations are not supported: " . implode(', ', $missing));
72 }
73 }
74 }
75 }