| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPSynchro\API; |
| 4 |
|
| 5 |
use WPSynchro\Status\MigrateStatus; |
| 6 |
|
| 7 |
/** |
| 8 |
* Class for handling service "status" |
| 9 |
* Call should already be verified by permissions callback |
| 10 |
* |
| 11 |
*/ |
| 12 |
class Status extends WPSynchroService |
| 13 |
{ |
| 14 |
public function service() |
| 15 |
{ |
| 16 |
// Extract parameters |
| 17 |
$body = $this->getRequestBody(); |
| 18 |
$parameters = json_decode($body); |
| 19 |
|
| 20 |
if (isset($parameters->migration_id)) { |
| 21 |
$migration_id = $parameters->migration_id; |
| 22 |
} else { |
| 23 |
$migration_id = ''; |
| 24 |
} |
| 25 |
if (isset($parameters->job_id)) { |
| 26 |
$job_id = $parameters->job_id; |
| 27 |
} else { |
| 28 |
$job_id = ''; |
| 29 |
} |
| 30 |
|
| 31 |
$status = new MigrateStatus(); |
| 32 |
$status->setup($migration_id, $job_id); |
| 33 |
$sync_response = $status->getMigrationStatus(); |
| 34 |
|
| 35 |
if (isset($sync_response->errors) && count($sync_response->errors) > 0) { |
| 36 |
$sync_response->should_continue = false; |
| 37 |
} else { |
| 38 |
$sync_response->should_continue = true; |
| 39 |
} |
| 40 |
|
| 41 |
echo json_encode($sync_response); |
| 42 |
} |
| 43 |
} |
| 44 |
|