Migration from Mailpoet 2 to Mailpoet 3 : phase 0
Interface
This commit is contained in:
47
lib/API/Endpoints/MP2MigratorAPI.php
Normal file
47
lib/API/Endpoints/MP2MigratorAPI.php
Normal 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()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user