Skip to main content

GravityKit\GravityMigrate\Exporters\AbstractExporter

Provides shared helper methods for exporter implementations.

Since: %ver%

Source: src/Exporters/AbstractExporter.php:35

Details​

  • Kind: class

  • Namespace: GravityKit\GravityMigrate\Exporters

  • Implements: ExporterInterface, PipelineContext

Properties​

PropertyTypeDescription
$slugstringExporter slug.
$namestringExporter display name.
$descriptionstringExporter description.
$utilUtilUtility helper instance.
$forms_dataFormsDataForms data helper.

Methods​

MethodDescription
__construct()AbstractExporter constructor.
list_forms()Returns a list of exportable Gravity Forms forms.
analyze_form()Reports what the requested Gravity Forms form loses on the way to the target provider.
export_form()Exports a Gravity Forms form to the target provider.
translate_merge_tags()Converts Gravity Forms merge tags into provider-specific tokens.
sanitize_text()Sanitizes plain text values.
sanitize_textarea()Sanitizes textarea values.
normalize_field_tree()Gravity Forms fields as arrays, a repeater's children included.
has_been_exported()Whether this form has already been exported to this destination.
get_tracked_import_id()The form this source form was migrated into before, if it was.

Method Reference​

__construct()​

public function __construct( Util $util, ?FormsData $forms_data=null )

AbstractExporter constructor.

Parameters​

NameTypeDefaultDescription
$utilUtilUtility helper instance.
$forms_dataFormsDatanullForms data helper.

Since: %ver%

Source: src/Exporters/AbstractExporter.php:139

list_forms()​

public function list_forms( array $args=[] ): array

Returns a list of exportable Gravity Forms forms.

Parameters​

NameTypeDefaultDescription
$argsarray[]Optional request arguments.

Returns​

  • array — Associative arrays carrying at least id and title.

Since: %ver%

Source: src/Exporters/AbstractExporter.php:149

analyze_form()​

public function analyze_form( $form_id, array $args=[] )

Reports what the requested Gravity Forms form loses on the way to the target provider.

Parameters​

NameTypeDefaultDescription
$form_idmixedGravity Forms form identifier.
$argsarray[]Optional request arguments.

Returns​

  • array | WP_Error — Field notices and warnings, or WP_Error when the form cannot be read.

Since: %ver%

Source: src/Exporters/AbstractExporter.php:171

export_form()​

public function export_form( $form_id, array $args=[] )

Exports a Gravity Forms form to the target provider.

Parameters​

NameTypeDefaultDescription
$form_idmixedGravity Forms form identifier.
$argsarray[]Optional request arguments.

Returns​

  • array | WP_Error — target_form_id, edit_url and issues for the created form, or WP_Error describing the failure.

Since: %ver%

Source: src/Exporters/AbstractExporter.php:178

translate_merge_tags()​

public function translate_merge_tags( string $text, array $context=[] ): string

Converts Gravity Forms merge tags into provider-specific tokens.

Parameters​

NameTypeDefaultDescription
$textstringText containing Gravity Forms merge tags.
$contextarray[]Optional context data for replacements.

Returns​

  • string

Since: %ver%

Source: src/Exporters/AbstractExporter.php:185

sanitize_text()​

public function sanitize_text( $value ): string

Sanitizes plain text values.

Parameters​

NameTypeDefaultDescription
$valuemixedValue to sanitize.

Returns​

  • string

Since: %ver%

Source: src/Exporters/AbstractExporter.php:198

sanitize_textarea()​

public function sanitize_textarea( $value ): string

Sanitizes textarea values.

Parameters​

NameTypeDefaultDescription
$valuemixedValue to sanitize.

Returns​

  • string

Since: %ver%

Source: src/Exporters/AbstractExporter.php:211

normalize_field_tree()​

public static function normalize_field_tree( array $fields ): array

Gravity Forms fields as arrays, a repeater's children included.

GF_Field has no to_array(). Only GF_Field_FileUpload defines one, converting a submitted file value rather than the field, so calling it throws an ArgumentCountError; get_object_vars() is the conversion that works for every field type.

Recurses into nested fields too: a repeater's children stay GF_Field objects otherwise, and every adapter's child loop guards with is_array( $child ), so an unconverted repeater would cross as an empty shell with nothing reported unsupported.

Parameters​

NameTypeDefaultDescription
$fieldsarrayFields, as objects or arrays, possibly holding nested fields.

Returns​

  • array — The same fields, all the way down, as arrays.

Since: %ver%

Source: src/Exporters/AbstractExporter.php:251

has_been_exported()​

public function has_been_exported( int $source_form_id ): bool

Whether this form has already been exported to this destination.

Parameters​

NameTypeDefaultDescription
$source_form_idintGravity Forms form ID.

Returns​

  • bool

Since: %ver%

Source: src/Exporters/AbstractExporter.php:473

get_tracked_import_id()​

public function get_tracked_import_id( $source_form_id ): ?int

The form this source form was migrated into before, if it was.

An export reads a Gravity Forms form and writes it somewhere else, so there is no earlier import of it to have tracked. Null is the truthful answer here rather than a placeholder.

Parameters​

NameTypeDefaultDescription
$source_form_idint | stringId of the form on the source platform.

Returns​

  • int | null — Target form id, or null when this is the first time.

Since: %ver%

Source: src/Exporters/AbstractExporter.php:1029