PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.10.2
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.10.2
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / back / Controllers / Dashboard / Migration.php

Migration.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.10.2, at back/Controllers/Dashboard/Migration.php

86 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\Controllers\Dashboard;
4
5 use AcyMailing\Helpers\MigrationHelper;
6 use AcyMailing\Helpers\UpdateHelper;
7
8 trait Migration
9 {
10 public function preMigration(): void
11 {
12 $elementToMigrate = acym_getVar('string', 'element', '');
13 $helperMigration = new MigrationHelper();
14
15 $result = $helperMigration->preMigration($elementToMigrate);
16
17 if (!empty($result['isOk'])) {
18 echo $result['count'];
19 } else {
20 $this->errorHandling($result);
21 }
22 exit;
23 }
24
25 public function migrate(): void
26 {
27 $elementToMigrate = acym_getVar('string', 'element');
28 $helperMigration = new MigrationHelper();
29 $functionName = 'do'.ucfirst($elementToMigrate).'Migration';
30
31 $result = $helperMigration->$functionName($elementToMigrate);
32
33 if (!empty($result['isOk'])) {
34 echo json_encode($result);
35 } else {
36 $this->errorHandling($result);
37 }
38 exit;
39 }
40
41 public function migrationDone(): void
42 {
43 $this->config->saveConfig(['migration' => 1]);
44
45 $updateHelper = new UpdateHelper();
46 $updateHelper->installNotifications();
47 $updateHelper->installTemplates();
48 $updateHelper->installOverrideEmails();
49
50 $this->listing();
51 }
52
53 private function errorHandling(array $result): void
54 {
55 echo 'ERROR : ';
56 if (!empty($result['errorInsert'])) {
57 echo strtoupper(acym_translation('ACYM_INSERT_ERROR'));
58 }
59 if (!empty($result['errorClean'])) {
60 echo strtoupper(acym_translation('ACYM_CLEAN_ERROR'));
61 }
62
63 if (!empty($result['errors'])) {
64 echo '<br>';
65
66 foreach ($result['errors'] as $key => $oneError) {
67 echo '<br>'.$key.' : '.$oneError;
68 }
69 }
70 }
71
72 public function migration(): bool
73 {
74 if ($this->config->get('migration') == 0 && acym_existsAcyMailing59()) {
75 acym_setVar('layout', 'migrate');
76 parent::display();
77
78 return true;
79 }
80
81 $this->config->saveConfig(['migration' => 1]);
82
83 return false;
84 }
85 }
86