Skip to main content

GravityKit\GravityMigrate\Schema\TransformationLog

Tracks the transformation history of forms and fields.

Each record says what changed, how severely, and what the value was before, so a migration can report what it dropped and a later one can tell it is bringing a form back where it started. Logs chain through previous, and the length of that chain is the number of trips a form has made.

Since: %ver%

Source: src/Schema/TransformationLog.php:20

Details

  • Kind: class

  • Namespace: GravityKit\GravityMigrate\Schema

  • Implements: JsonSerializable

Properties

PropertyTypeDescription
$source_platformstringSource platform identifier.
$source_idstring | intSource identifier (form ID, field ID, etc.).
$target_platformstringTarget platform identifier.
$target_idstring | intTarget identifier.
$transformationsarray<array>Transformation records.
$created_atintTimestamp of creation.
$previousTransformationLog | nullPrevious transformation log in chain (for round-trips).

Methods

MethodDescription
__construct()Constructor.
record()Records a transformation.
record_field_type_change()Records a field type transformation.
record_property_change()Records a property transformation.
record_smart_tag_change()Records a smart tag transformation.
record_composite_operation()Records a composite field operation.
record_data_loss()Records a lossy transformation with warning.
get_transformations()Gets all transformations.
get_transformations_by_category()Gets transformations by category.
get_transformations_by_severity()Gets transformations by severity.
has_data_loss()Checks if any lossy transformations occurred.
get_data_loss_summary()Gets a summary of data loss.
set_source()Sets the source information.
set_target()Sets the target information.
get_source_platform()Gets source platform.
get_source_id()Gets source ID.
get_target_platform()Gets target platform.
get_target_id()Gets target ID.
link_previous()Links to a previous transformation log (for round-trips).
get_previous()Gets the previous transformation log.
is_round_trip()Checks if this is part of a round-trip.
get_round_trip_depth()Gets the round-trip depth.
from_array()Creates from array.
to_array()Converts to array.

Method Reference

__construct()

public function __construct( string $source_platform='', $source_id='', string $target_platform='', $target_id='' )

Constructor.

Parameters

NameTypeDefaultDescription
$source_platformstring''Source platform.
$source_idstring | int''Source identifier.
$target_platformstring''Target platform.
$target_idstring | int''Target identifier.

Since: %ver%

Source: src/Schema/TransformationLog.php:124

record()

public function record( string $type, string $category, string $severity, string $description, array $original_data=[], array $result_data=[], array $metadata=[] ): self

Records a transformation.

Parameters

NameTypeDefaultDescription
$typestringTransformation type.
$categorystringTransformation category.
$severitystringSeverity level.
$descriptionstringHuman-readable description.
$original_dataarray[]Original data before transformation.
$result_dataarray[]Resulting data after transformation.
$metadataarray[]Additional metadata.

Returns

  • self

Since: %ver%

Source: src/Schema/TransformationLog.php:152

record_field_type_change()

public function record_field_type_change( string $source_type, string $target_type, string $severity=self::SEVERITY_LOSSLESS, array $metadata=[] ): self

Records a field type transformation.

Parameters

NameTypeDefaultDescription
$source_typestringSource field type.
$target_typestringTarget field type.
$severitystringself::SEVERITY_LOSSLESSSeverity level.
$metadataarray[]Additional metadata.

Returns

  • self

Since: %ver%

Source: src/Schema/TransformationLog.php:187

record_property_change()

public function record_property_change( string $property, $original, $result, string $severity=self::SEVERITY_LOSSLESS, array $metadata=[] ): self

Records a property transformation.

Parameters

NameTypeDefaultDescription
$propertystringProperty name.
$originalmixedOriginal value.
$resultmixedResult value.
$severitystringself::SEVERITY_LOSSLESSSeverity level.
$metadataarray[]Additional metadata.

Returns

  • self

Since: %ver%

Source: src/Schema/TransformationLog.php:217

record_smart_tag_change()

public function record_smart_tag_change( string $original, string $result, array $metadata=[] ): self

Records a smart tag transformation.

Parameters

NameTypeDefaultDescription
$originalstringOriginal tag.
$resultstringResult tag.
$metadataarray[]Additional metadata.

Returns

  • self

Since: %ver%

Source: src/Schema/TransformationLog.php:246

record_composite_operation()

public function record_composite_operation( string $operation, array $source_ids, $target_id, array $metadata=[] ): self

Records a composite field operation.

Parameters

NameTypeDefaultDescription
$operationstringOperation type (recompose, decompose).
$source_idsarraySource field IDs.
$target_idmixedTarget field ID.
$metadataarray[]Additional metadata.

Returns

  • self

Since: %ver%

Source: src/Schema/TransformationLog.php:274

record_data_loss()

public function record_data_loss( string $category, string $description, array $lost_data, array $metadata=[] ): self

Records a lossy transformation with warning.

Parameters

NameTypeDefaultDescription
$categorystringCategory.
$descriptionstringDescription.
$lost_dataarrayData that was lost.
$metadataarray[]Additional metadata.

Returns

  • self

Since: %ver%

Source: src/Schema/TransformationLog.php:307

get_transformations()

public function get_transformations(): array

Gets all transformations.

Returns

  • array

Since: %ver%

Source: src/Schema/TransformationLog.php:331

get_transformations_by_category()

public function get_transformations_by_category( string $category ): array

Gets transformations by category.

Parameters

NameTypeDefaultDescription
$categorystringCategory to filter by.

Returns

  • array — The matching records, keeping their original keys rather than renumbered.

Since: %ver%

Source: src/Schema/TransformationLog.php:344

get_transformations_by_severity()

public function get_transformations_by_severity( string $severity ): array

Gets transformations by severity.

Parameters

NameTypeDefaultDescription
$severitystringSeverity to filter by.

Returns

  • array — The matching records, keeping their original keys rather than renumbered.

Since: %ver%

Source: src/Schema/TransformationLog.php:360

has_data_loss()

public function has_data_loss(): bool

Checks if any lossy transformations occurred.

Returns

  • bool

Since: %ver%

Source: src/Schema/TransformationLog.php:374

get_data_loss_summary()

public function get_data_loss_summary(): array

Gets a summary of data loss.

Returns

  • array

Since: %ver%

Source: src/Schema/TransformationLog.php:391

set_source()

public function set_source( string $platform, $id ): self

Sets the source information.

Parameters

NameTypeDefaultDescription
$platformstringPlatform identifier.
$idstring | intSource identifier.

Returns

  • self

Since: %ver%

Source: src/Schema/TransformationLog.php:417

set_target()

public function set_target( string $platform, $id ): self

Sets the target information.

Parameters

NameTypeDefaultDescription
$platformstringPlatform identifier.
$idstring | intTarget identifier.

Returns

  • self

Since: %ver%

Source: src/Schema/TransformationLog.php:434

get_source_platform()

public function get_source_platform(): string

Gets source platform.

Returns

  • string

Since: %ver%

Source: src/Schema/TransformationLog.php:448

get_source_id()

public function get_source_id()

Gets source ID.

Returns

  • string | int

Since: %ver%

Source: src/Schema/TransformationLog.php:459

get_target_platform()

public function get_target_platform(): string

Gets target platform.

Returns

  • string

Since: %ver%

Source: src/Schema/TransformationLog.php:470

get_target_id()

public function get_target_id()

Gets target ID.

Returns

  • string | int

Since: %ver%

Source: src/Schema/TransformationLog.php:481

public function link_previous( TransformationLog $previous ): self

Links to a previous transformation log (for round-trips).

Parameters

NameTypeDefaultDescription
$previousTransformationLogPrevious transformation log.

Returns

  • self

Since: %ver%

Source: src/Schema/TransformationLog.php:494

get_previous()

public function get_previous(): ?TransformationLog

Gets the previous transformation log.

Returns

  • TransformationLog | null

Since: %ver%

Source: src/Schema/TransformationLog.php:507

is_round_trip()

public function is_round_trip(): bool

Checks if this is part of a round-trip.

Returns

  • bool

Since: %ver%

Source: src/Schema/TransformationLog.php:518

get_round_trip_depth()

public function get_round_trip_depth(): int

Gets the round-trip depth.

Returns

  • int

Since: %ver%

Source: src/Schema/TransformationLog.php:529

from_array()

public static function from_array( array $data ): self

Creates from array.

Parameters

NameTypeDefaultDescription
$dataarrayArray data.

Returns

  • self

Since: %ver%

Source: src/Schema/TransformationLog.php:580

to_array()

public function to_array(): array

Converts to array.

Returns

  • array

Since: %ver%

Source: src/Schema/TransformationLog.php:615