Skip to main content

GravityKit\GravityMigrate\Exporters\Controller

Handles AJAX endpoints for exporting Gravity Forms to third-party providers.

Since: %ver%

Source: src/Exporters/Controller.php:29

Details

  • Kind: class
  • Namespace: GravityKit\GravityMigrate\Exporters

Properties

PropertyTypeDescription
$registryTargetRegistryExporter registry.
$utilUtilUtility helper.

Methods

MethodDescription
__construct()Controller constructor.
register_routes()Registers controller routes with GravityKit Foundation.
list_exporters()Returns available exporters.
list_forms()Returns Gravity Forms forms for export.
analyze_forms()Analyses several forms in one request.
analyze_form()Analyses a form for export.
map_by_label()Pairs of label and value as a map, dropping any label that names two different values.
export_form()Exports a form to a provider.

Method Reference

__construct()

public function __construct( TargetRegistry $registry )

Controller constructor.

Parameters

NameTypeDefaultDescription
$registryTargetRegistryExporter registry instance.

Since: %ver%

Source: src/Exporters/Controller.php:90

register_routes()

public function register_routes( $routes ): array

Registers controller routes with GravityKit Foundation.

Parameters

NameTypeDefaultDescription
$routesarrayExisting routes.

Returns

  • array

Since: %ver%

Source: src/Exporters/Controller.php:106

list_exporters()

public function list_exporters( $payload ): array

Returns available exporters.

Parameters

NameTypeDefaultDescription
$payloadarrayRequest payload.

Returns

  • array

Since: %ver%

Source: src/Exporters/Controller.php:123

list_forms()

public function list_forms( $payload ): array

Returns Gravity Forms forms for export.

Parameters

NameTypeDefaultDescription
$payloadarrayRequest payload.

Returns

  • array

Since: %ver%

Source: src/Exporters/Controller.php:170

analyze_forms()

public function analyze_forms( $payload ): array

Analyses several forms in one request.

The Forms step asks what each form loses on the way across, and asked once per form: a site with a hundred forms paid for a hundred WordPress boots to do a few milliseconds of work each. Everything expensive -- validating the request, resolving the provider, fetching the exporter -- happens once here for the whole set.

A form that cannot be read is reported against its own id rather than thrown, because the screen marks one card per form: a batch that failed whole would blank a screenful of answers over one bad form. Only failures that apply to every id equally -- a bad nonce, a missing capability, an unavailable exporter -- refuse the request.

Parameters

NameTypeDefaultDescription
$payloadarrayRequest payload.

Returns

  • array

Since: %ver%

Source: src/Exporters/Controller.php:276

analyze_form()

public function analyze_form( $payload ): array

Analyses a form for export.

Parameters

NameTypeDefaultDescription
$payloadarrayRequest payload.

Returns

  • array

Since: %ver%

Source: src/Exporters/Controller.php:348

map_by_label()

public static function map_by_label( array $pairs ): array

Pairs of label and value as a map, dropping any label that names two different values.

The export report describes fields by label, and labels are not unique. Where two fields share one, saying either value beside the other states something false, so the label is dropped and the row is left plain.

Three walks over the same form build maps this way and only one of them did it: the readable type dropped an ambiguous label while the universal type kept whichever field came last, so a verdict could be computed from another field's type and a row read "Stays the same" about a field that had changed. One rule here, so they cannot drift apart again.

Parameters

NameTypeDefaultDescription
$pairsarray

Returns

  • array<string, — string>

Since: %ver%

Source: src/Exporters/Controller.php:445

export_form()

public function export_form( $payload ): array

Exports a form to a provider.

Parameters

NameTypeDefaultDescription
$payloadarrayRequest payload.

Returns

  • array

Since: %ver%

Source: src/Exporters/Controller.php:693