Skip to main content

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

PropertyTypeDescription
$gateway_overrideobject | nullTest seam: overrides the scheduler gateway run() resolves against.
$step_runner_overridecallable | nullTest seam: overrides the step runner run() loops instead of resolving it from the

Methods

MethodDescription
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

NameTypeDefaultDescription
$gatewayobject | nullScripted 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

NameTypeDefaultDescription
$step_runnercallable | nullScripted 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

NameTypeDefaultDescription
$argsarray[]Task args. Read for should_continue()'s deadline.
$job_dataarray | nullnullShared 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