GravityKit\GravityMigrate\Background\ImportJobDriver
Continues a Gravity Forms import across Foundation scheduler task executions.
Every slice this driver runs is the same import AJAX route closure the browser posts to and
CLI\Migrate::drive_import() loops -- called here with the last round-tripped payload in
place of a browser round-trip. The import's own state machine lives entirely in the payload
Import::import() returns; this class only drives it one cooperative slice per task
execution, persisting that payload into Options::BG_IMPORT_STATE between slices so a resumed
task execution (or the status route) can pick it back up.
Since: %ver%
Source: src/Background/ImportJobDriver.php:28
Details
- Kind:
class - Namespace:
GravityKit\GravityMigrate\Background
Properties
| Property | Type | Description |
|---|---|---|
$gateway_override | object | null | Test seam: overrides the scheduler gateway run() resolves against. |
$step_runner_override | callable | null | Test seam: overrides the step runner run() loops instead of resolving it from the |
Methods
| Method | Description |
|---|---|
set_gateway_for_testing() | Sets the scheduler gateway a test wants run() to use. |
set_step_runner_for_testing() | Sets the step runner a test wants run() to loop instead of the real import route. |
run() | Runs one cooperative slice of a background import. |
Method Reference
set_gateway_for_testing()
public static function set_gateway_for_testing( $gateway ): void
Sets the scheduler gateway a test wants run() to use.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$gateway | object | null | Scripted gateway double, or null to clear the override. |
Returns
void
Since: %ver%
Source: src/Background/ImportJobDriver.php:58
set_step_runner_for_testing()
public static function set_step_runner_for_testing( ?callable $step_runner ): void
Sets the step runner a test wants run() to loop instead of the real import route.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$step_runner | callable | null | Scripted step runner, or null to clear the override. |
Returns
void
Since: %ver%
Source: src/Background/ImportJobDriver.php:71
run()
public static function run( array $args=[], $job_data=null )
Runs one cooperative slice of a background import.
Reads the import's persisted round-trip payload, impersonates the user who scheduled the
job, and loops the import's import() step until it reports completion, the scheduler's
time budget for this task execution runs out, or a step throws.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$args | array | [] | Task args. Read for should_continue()'s deadline. |
$job_data | array | null | null | Shared job data. Must carry the scheduling job_id. |
Returns
mixed— The gateway's checkpoint/completion result.
Throws
Exception— When the persisted state cannot be resumed against this job.Throwable— When a step throws; rethrown after the state is marked failed.
Since: %ver%
Source: src/Background/ImportJobDriver.php:92