- Finishes import migration

- Updates models
- Improves Notice.js
This commit is contained in:
MrCasual
2015-11-06 21:28:24 -05:00
parent 158d26ef86
commit 3f168d052f
16 changed files with 586 additions and 139 deletions

View File

@@ -21,14 +21,13 @@ class Import {
function addSegment($data) {
$segment = Segment::createOrUpdate($data, $returnObject = true);
wp_send_json(
(!is_array($segment)) ?
(!is_object($segment)) ?
array(
'status' => 'error',
'message' => $segment
'result' => false,
) :
array(
'status' => 'success',
'segment' => $segment
'result' => true,
'segment' => $segment->asArray()
)
);
}
@@ -40,17 +39,27 @@ class Import {
wp_send_json(
(!$result) ?
array(
'status' => 'error'
'result' => false
) :
array(
'status' => 'success',
'result' => true,
'customField' => $customField->asArray()
)
);
}
function process($data) {
$data = file_get_contents(dirname(__FILE__) . '/../../export.txt');
$import = new \MailPoet\Import\Import(json_decode($data, true));
wp_send_json($import->process());
try {
wp_send_json($import->process());
} catch (\Exception $e) {
wp_send_json(
array(
'result' => false,
'error' => $e->getMessage()
)
);
}
}
}