preMigration($elementToMigrate); if (!empty($result['isOk'])) { echo $result['count']; } else { $this->errorHandling($result); } exit; } public function migrate(): void { $elementToMigrate = acym_getVar('string', 'element'); $helperMigration = new MigrationHelper(); $functionName = 'do'.ucfirst($elementToMigrate).'Migration'; $result = $helperMigration->$functionName($elementToMigrate); if (!empty($result['isOk'])) { echo json_encode($result); } else { $this->errorHandling($result); } exit; } public function migrationDone(): void { $newConfig = new \stdClass(); $newConfig->migration = '1'; $this->config->save($newConfig); $updateHelper = new UpdateHelper(); $updateHelper->installNotifications(); $updateHelper->installTemplates(); $updateHelper->installOverrideEmails(); $this->listing(); } private function errorHandling(array $result): void { echo 'ERROR : '; if (!empty($result['errorInsert'])) { echo strtoupper(acym_translation('ACYM_INSERT_ERROR')); } if (!empty($result['errorClean'])) { echo strtoupper(acym_translation('ACYM_CLEAN_ERROR')); } if (!empty($result['errors'])) { echo '
'; foreach ($result['errors'] as $key => $oneError) { echo '
'.$key.' : '.$oneError; } } } private function acym_existsAcyMailing59(): bool { $allTables = acym_getTables(); if (in_array(acym_getPrefix().'acymailing_config', $allTables)) { $queryVersion = 'SELECT `value` FROM #__acymailing_config WHERE `namekey` LIKE "version"'; $version = acym_loadResult($queryVersion); if (version_compare($version, '5.9.0') >= 0) { return true; } } return false; } public function migration(): bool { if ($this->config->get('migration') == 0 && acym_existsAcyMailing59()) { acym_setVar('layout', 'migrate'); parent::display(); return true; } $newConfig = new \stdClass(); $newConfig->migration = '1'; $this->config->save($newConfig); return false; } }