-
Notifications
You must be signed in to change notification settings - Fork 1
/
ExampleMigrationTask.php
43 lines (37 loc) · 1.23 KB
/
ExampleMigrationTask.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php declare(strict_types=1);
namespace TheFrosty\WpUpgradeTaskRunner\Tasks;
use TheFrosty\WpUpgradeTaskRunner\Api\AbstractTaskRunner;
use TheFrosty\WpUpgradeTaskRunner\Models\UpgradeModel;
/**
* Class ExampleMigrationTask
*
* @package TheFrosty\WpUpgradeTaskRunner\Tasks
* phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_error_log
*/
class ExampleMigrationTask extends AbstractTaskRunner
{
public const DATE = '2018-05-23';
public const DESCRIPTION = 'This is an example upgrade/migration task. It does not do anything
except sleep for five seconds before it "completes" it\'s task.';
public const TITLE = 'Example Migration Task';
/**
* Dispatch the migration task.
*
* @param UpgradeModel $model
*/
public function dispatch(UpgradeModel $model): void
{
\error_log(\sprintf('[Migration] %s is running...', self::class));
$this->longRunningTask();
$this->clearScheduledEvent(static::class, $model);
$this->complete($model);
\error_log(\sprintf('[Migration] %s completed successfully.', self::class));
}
/**
* Example task that needs to "run".
*/
private function longRunningTask(): void
{
\sleep(5);
}
}