Skip to main content

GravityKit\GravityMigrate\Schema\FormLink

The link between a form and the one made from it, readable from either end.

A migration needs both directions. Going forward answers "has this form been migrated already", which decides whether a second run updates the form it made or makes another one. Going back answers "where did this form come from", which is what a later export reads.

Only the forward direction is held. The reverse is derived on the way out, so a link cannot be written halfway and the two directions cannot disagree.

Since: %ver%

Source: src/Schema/FormLink.php:22

Details

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

Methods

MethodDescription
from_array()Reads a stored pair of maps.
link()Records that a form was made from another, replacing whatever either end pointed at.
target_for()The form made from this one, or null.
source_for()The form this one was made from, or null.
forget_source()Forgets a source, and the form it made.
forget_target()Forgets a target, and the source it came from.
is_empty()Whether anything is linked.
to_array()The link as the pair of maps that gets stored.

Method Reference

from_array()

public static function from_array( array $stored ): self

Reads a stored pair of maps.

Only the forward map is read. Older records can carry a reverse map that no longer agrees with it; rebuilding from the forward map drops those stale entries.

Parameters

NameTypeDefaultDescription
$storedarrayA record holding sources and targets.

Returns

  • self

Since: %ver%

Source: src/Schema/FormLink.php:53

public function link( $source_id, $target_id ): self

Records that a form was made from another, replacing whatever either end pointed at.

Both ends are cleared first, so a source that previously made a different form and a target that previously came from a different source each stop pointing at a form that has moved on.

Parameters

NameTypeDefaultDescription
$source_idstring | intId on the platform the form came from.
$target_idstring | intId of the form made from it.

Returns

  • self

Since: %ver%

Source: src/Schema/FormLink.php:77

target_for()

public function target_for( $source_id )

The form made from this one, or null.

Parameters

NameTypeDefaultDescription
$source_idstring | intId on the platform the form came from.

Returns

  • string | int | null

Since: %ver%

Source: src/Schema/FormLink.php:95

source_for()

public function source_for( $target_id )

The form this one was made from, or null.

Parameters

NameTypeDefaultDescription
$target_idstring | intId of the form made by a migration.

Returns

  • string | int | null

Since: %ver%

Source: src/Schema/FormLink.php:108

forget_source()

public function forget_source( $source_id ): self

Forgets a source, and the form it made.

Parameters

NameTypeDefaultDescription
$source_idstring | intId on the platform the form came from.

Returns

  • self

Since: %ver%

Source: src/Schema/FormLink.php:129

forget_target()

public function forget_target( $target_id ): self

Forgets a target, and the source it came from.

Parameters

NameTypeDefaultDescription
$target_idstring | intId of the form made by a migration.

Returns

  • self

Since: %ver%

Source: src/Schema/FormLink.php:144

is_empty()

public function is_empty(): bool

Whether anything is linked.

Returns

  • bool

Since: %ver%

Source: src/Schema/FormLink.php:161

to_array()

public function to_array(): array

The link as the pair of maps that gets stored.

The stored record carries both directions. The reverse map is derived here rather than kept, so it cannot drift from the forward one.

Returns

  • array{sources: — array, targets: array}

Since: %ver%

Source: src/Schema/FormLink.php:175