Skip to main content

GravityKit\GravityMigrate\Exporters\AbstractExporter

Provides shared helper methods for exporter implementations.

Since: %ver%

Source: src/Exporters/AbstractExporter.php:33

Details

  • Kind: class

  • Namespace: GravityKit\GravityMigrate\Exporters

  • Implements: ExporterInterface, PipelineContext

Properties

PropertyTypeDescription
$slugstringExporter slug.
$namestringExporter display name.
$descriptionstringExporter description.
$minimum_capabilitystringMinimum capability required to use the exporter.
$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:108

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:118

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:140

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_Errortarget_form_id, edit_url and issues for the created form, or WP_Error describing the failure.

Since: %ver%

Source: src/Exporters/AbstractExporter.php:147

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:154

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:167

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:180

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, and it converts a submitted file value rather than the field, so method_exists() is true for exactly one field type and calling it throws an ArgumentCountError -- which would stop any form holding a file upload from exporting anywhere. get_object_vars() is the conversion that works.

Nested fields are converted too. A repeater's children stay GF_Field objects when only the top level is converted, and every adapter guards its child loop with is_array( $child ), so the repeater would go across 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:231

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:345

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:946