Skip to main content

GravityKit\GravityMigrate\Schema\FieldMapper

Maps field types bidirectionally between platforms.

Platform → Universal → Platform translation, with an assessment of what a conversion loses and whether it can be reversed.

Since: %ver%

Source: src/Schema/FieldMapper.php:20

Details​

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

Methods​

MethodDescription
normalize_platform()Normalizes a platform identifier to its canonical underscored id.
to_universal()Maps a field type from source platform to universal type.
from_universal()Maps a universal field type to target platform type.
fallback_type()Returns the plain text field type for a platform, used when nothing else matches.
map_between_platforms()Maps a field type directly between platforms.
assess_round_trip_fidelity()Whether a field type survives being exported and brought back.
get_supported_types()Gets all supported field types for a platform.
is_supported()Checks if a field type is supported by a platform.
get_universal_to_platform_map_for()Gets the universal-to-platform mapping for a platform.

Method Reference​

normalize_platform()​

public static function normalize_platform( string $platform ): string

Normalizes a platform identifier to its canonical underscored id.

Parameters​

NameTypeDefaultDescription
$platformstringPlatform identifier (canonical or runtime slug).

Returns​

  • string — Canonical platform id.

Since: %ver%

Source: src/Schema/FieldMapper.php:100

to_universal()​

public static function to_universal( string $source_type, string $platform ): string

Maps a field type from source platform to universal type.

Parameters​

NameTypeDefaultDescription
$source_typestringSource field type.
$platformstringSource platform identifier.

Returns​

  • string — Universal field type.

Since: %ver%

Source: src/Schema/FieldMapper.php:114

from_universal()​

public static function from_universal( string $universal_type, string $platform ): string

Maps a universal field type to target platform type.

Parameters​

NameTypeDefaultDescription
$universal_typestringUniversal field type.
$platformstringTarget platform identifier.

Returns​

  • string — Target platform field type.

Since: %ver%

Source: src/Schema/FieldMapper.php:130

fallback_type()​

public static function fallback_type( string $platform ): string

Returns the plain text field type for a platform, used when nothing else matches.

Parameters​

NameTypeDefaultDescription
$platformstringTarget platform identifier.

Returns​

  • string

Since: %ver%

Source: src/Schema/FieldMapper.php:152

map_between_platforms()​

public static function map_between_platforms( string $source_type, string $source_platform, string $target_platform ): array

Maps a field type directly between platforms.

Parameters​

NameTypeDefaultDescription
$source_typestringSource field type.
$source_platformstringSource platform identifier.
$target_platformstringTarget platform identifier.

Returns​

  • array — Carries 'type', 'universal_type', 'is_lossy', 'is_exact_match', 'loss_description' and 'transformation_log_severity'.

Since: %ver%

Source: src/Schema/FieldMapper.php:170

assess_round_trip_fidelity()​

public static function assess_round_trip_fidelity( string $original_type, string $source_platform, string $target_platform ): array

Whether a field type survives being exported and brought back.

Parameters​

NameTypeDefaultDescription
$original_typestringOriginal field type.
$source_platformstringOriginal source platform.
$target_platformstringPlatform it was exported to.

Returns​

  • array — Carries 'can_restore', 'restored_type', 'intermediate_type', 'fidelity_loss' and 'is_lossless'.

Since: %ver%

Source: src/Schema/FieldMapper.php:240

get_supported_types()​

public static function get_supported_types( string $platform ): array

Gets all supported field types for a platform.

Parameters​

NameTypeDefaultDescription
$platformstringPlatform identifier.

Returns​

  • array — List of supported field types.

Since: %ver%

Source: src/Schema/FieldMapper.php:281

is_supported()​

public static function is_supported( string $field_type, string $platform ): bool

Checks if a field type is supported by a platform.

Parameters​

NameTypeDefaultDescription
$field_typestringField type to check.
$platformstringPlatform identifier.

Returns​

  • bool

Since: %ver%

Source: src/Schema/FieldMapper.php:297

get_universal_to_platform_map_for()​

public static function get_universal_to_platform_map_for( string $platform ): array

Gets the universal-to-platform mapping for a platform.

Parameters​

NameTypeDefaultDescription
$platformstringPlatform identifier.

Returns​

  • array

Since: %ver%

Source: src/Schema/FieldMapper.php:334