| 1 |
<?php |
| 2 |
|
| 3 |
namespace BitCode\BitForm\Core\Migration; |
| 4 |
|
| 5 |
// create class for migration |
| 6 |
final class Migration { |
| 7 |
private $_formData; |
| 8 |
|
| 9 |
public function __construct($data) { |
| 10 |
$this->_formData = $data; |
| 11 |
} |
| 12 |
|
| 13 |
// create function for migration |
| 14 |
public function migrate() { |
| 15 |
$formData = $this->_formData; |
| 16 |
|
| 17 |
$formData->form_content = self::convertFormContent($formData->form_content); |
| 18 |
$formData->workFlows = WorkFlows::migrate($formData->workFlows); |
| 19 |
$formData->formSettings = self::convertFormSettings($formData->formSettings); |
| 20 |
return $formData; |
| 21 |
} |
| 22 |
|
| 23 |
public function convertFormContent($formContentV1) { |
| 24 |
$formContenV2 = $formContentV1; |
| 25 |
|
| 26 |
if (isset($formContentV1->fields)) { |
| 27 |
$formContenV2->fields = MigrationHelper::convertFields($formContentV1->fields); |
| 28 |
} |
| 29 |
if (isset($formContentV1->layout)) { |
| 30 |
$formContenV2->layout = MigrationHelper::convertLayout($formContentV1->layout); |
| 31 |
} |
| 32 |
|
| 33 |
return $formContenV2; |
| 34 |
} |
| 35 |
|
| 36 |
public function convertFormSettings($formSettingsV1) { |
| 37 |
$formSettingsV2 = $formSettingsV1; |
| 38 |
if (isset($formSettingsV1->confirmation->type->successMsg)) { |
| 39 |
$formSettingsV2->confirmation->type->successMsg = MigrationHelper::convertSuccessMessage($formSettingsV1->confirmation->type->successMsg); |
| 40 |
} |
| 41 |
return $formSettingsV2; |
| 42 |
} |
| 43 |
} |
| 44 |
|