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
| Property | Type | Description |
|---|---|---|
$slug | string | Exporter slug. |
$name | string | Exporter display name. |
$description | string | Exporter description. |
$minimum_capability | string | Minimum capability required to use the exporter. |
$util | Util | Utility helper instance. |
$forms_data | FormsData | Forms data helper. |
Methods
| Method | Description |
|---|---|
__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
| Name | Type | Default | Description |
|---|---|---|---|
$util | Util | Utility helper instance. | |
$forms_data | FormsData | null | Forms 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
| Name | Type | Default | Description |
|---|---|---|---|
$args | array | [] | Optional request arguments. |
Returns
array— Associative arrays carrying at leastidandtitle.
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
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | mixed | Gravity Forms form identifier. | |
$args | array | [] | 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
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | mixed | Gravity Forms form identifier. | |
$args | array | [] | Optional request arguments. |
Returns
array| WP_Error —target_form_id,edit_urlandissuesfor 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
| Name | Type | Default | Description |
|---|---|---|---|
$text | string | Text containing Gravity Forms merge tags. | |
$context | array | [] | 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
| Name | Type | Default | Description |
|---|---|---|---|
$value | mixed | Value to sanitize. |
Returns
string
Since: %ver%
Source: src/Exporters/AbstractExporter.php:167
sanitize_textarea()
public function sanitize_textarea( $value ): string
Sanitizes textarea values.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$value | mixed | Value 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
| Name | Type | Default | Description |
|---|---|---|---|
$fields | array | Fields, 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
| Name | Type | Default | Description |
|---|---|---|---|
$source_form_id | int | Gravity 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
| Name | Type | Default | Description |
|---|---|---|---|
$source_form_id | int | string | Id 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