| 1 |
<?php |
| 2 |
/** |
| 3 |
* Batch Task |
| 4 |
* |
| 5 |
* @since 4.0.0 |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace wpCloud\StatelessMedia\Batch; |
| 9 |
|
| 10 |
abstract class Migration extends BatchTask { |
| 11 |
// Indicates whether we should stop querying new items |
| 12 |
protected $stop = false; |
| 13 |
|
| 14 |
public function get_state() { |
| 15 |
$state = parent::get_state(); |
| 16 |
|
| 17 |
$state['id'] = $this->id; |
| 18 |
$state['is_migration'] = true; |
| 19 |
$state['stop'] = $this->stop; |
| 20 |
|
| 21 |
return $state; |
| 22 |
} |
| 23 |
|
| 24 |
public function set_state($state) { |
| 25 |
parent::set_state($state); |
| 26 |
|
| 27 |
$this->stop = $state['stop'] ?? false; |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Can be used to test if the migration should run |
| 32 |
* For example, if there are any old data that needs to be migrated |
| 33 |
*/ |
| 34 |
public function should_run() { |
| 35 |
return true; |
| 36 |
} |
| 37 |
} |
| 38 |
|