Migration from Mailpoet 2 to Mailpoet 3 : phase 0

Interface
This commit is contained in:
fred
2017-04-14 23:39:26 +02:00
parent 502250a1a3
commit dd7f959731
10 changed files with 588 additions and 29 deletions

View File

@ -0,0 +1,47 @@
<?php
namespace MailPoet\API\Endpoints;
use MailPoet\API\Endpoint as APIEndpoint;
if(!defined('ABSPATH')) exit;
class MP2MigratorAPI extends APIEndpoint {
public function __construct() {
$this->MP2Migrator = new \MailPoet\Config\MP2Migrator();
}
/**
* Import end point
*
* @param object $data
* @return object
*/
public function import($data) {
try {
$process = $this->MP2Migrator->import(json_decode($data, true));
return $this->successResponse($process);
} catch(\Exception $e) {
return $this->errorResponse(array(
$e->getCode() => $e->getMessage()
));
}
}
/**
* Stop import end point
*
* @param object $data
* @return object
*/
public function stopImport($data) {
try {
$process = $this->MP2Migrator->stop_import();
return $this->successResponse($process);
} catch(\Exception $e) {
return $this->errorResponse(array(
$e->getCode() => $e->getMessage()
));
}
}
}