Files
piratepoet/lib/API/JSON/v1/MP2Migrator.php
Jan Jakeš 01a0fe96c4 Remove no longer necessary checks
[MAILPOET-1948]
2019-09-12 13:59:32 +02:00

72 lines
1.5 KiB
PHP

<?php
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\Config\AccessControl;
class MP2Migrator extends APIEndpoint {
public $permissions = [
'global' => AccessControl::PERMISSION_MANAGE_SETTINGS,
];
/** @var \MailPoet\Config\MP2Migrator */
private $MP2Migrator;
public function __construct(\MailPoet\Config\MP2Migrator $MP2Migrator) {
$this->MP2Migrator = $MP2Migrator;
}
/**
* Import end point
*
* @param object $data
* @return object
*/
public function import($data) {
try {
$process = $this->MP2Migrator->import();
return $this->successResponse($process);
} catch (\Exception $e) {
return $this->errorResponse([
$e->getCode() => $e->getMessage(),
]);
}
}
/**
* Stop import end point
*
* @param object $data
* @return object
*/
public function stopImport($data) {
try {
$process = $this->MP2Migrator->stopImport();
return $this->successResponse($process);
} catch (\Exception $e) {
return $this->errorResponse([
$e->getCode() => $e->getMessage(),
]);
}
}
/**
* Skip import end point
*
* @param object $data
* @return object
*/
public function skipImport($data) {
try {
$process = $this->MP2Migrator->skipImport();
return $this->successResponse($process);
} catch (\Exception $e) {
return $this->errorResponse([
$e->getCode() => $e->getMessage(),
]);
}
}
}