GravityKit\GravityMigrate\DataTypes
The names the operator chose their data by, reusable wherever a migration reports what it is
doing.
Labels come back unescaped, so a caller rendering into HTML must escape and one sending JSON
to a component that renders text must not -- an escaped & would print literally there.
Since: %ver%
Source: src/DataTypes.php:19
Details
- Kind:
class - Namespace:
GravityKit\GravityMigrate
Methods
| Method | Description |
|---|---|
label() | A data type's display name. |
site_settings_in() | The site-settings entries within a selection. |
is_site_setting() | Whether a data type writes this site's settings rather than its form data. |
all() | Every data type a migration reports progress for, as id => label. |
icons() | Icon URLs for the data types that have one, as id => URL. |
for_import_step() | The data type an import step belongs to. |
for_import_phase() | The data type an importer phase advances, or '' for a phase that moves no selection. |
for_import_phases() | The selections an importer result reports as finished. |
summary() | The data types a finished migration moved, ready to render. |
mark_completed() | Adds a data type to a completed list, in the order the run finished them. |
Method Reference
label()
public static function label( string $data_type ): string
A data type's display name.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$data_type | string | A data-type id as used in the export/import payloads. |
Returns
string— The label, or the id title-cased when the type has no label of its own.
Since: %ver%
Source: src/DataTypes.php:29
site_settings_in()
public static function site_settings_in( array $data_types ): array
The site-settings entries within a selection.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$data_types | array | Selected data-type ids. |
Returns
array— Those that are site settings, in the order given.
Since: %ver%
Source: src/DataTypes.php:106
is_site_setting()
public static function is_site_setting( string $data_type ): bool
Whether a data type writes this site's settings rather than its form data.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$data_type | string | A data-type id. |
Returns
bool
Since: %ver%
Source: src/DataTypes.php:126
all()
public static function all(): array
Every data type a migration reports progress for, as id => label.
Returns
array<string,string>
Since: %ver%
Source: src/DataTypes.php:137
icons()
public static function icons(): array
Icon URLs for the data types that have one, as id => URL.
The set is deliberately partial: a type with no icon is rendered by its label alone rather than by a stand-in.
Returns
array<string,string>— Empty when the plugin's URL constant is not defined.
Since: %ver%
Source: src/DataTypes.php:158
for_import_step()
public static function for_import_step( string $step ): string
The data type an import step belongs to.
The importer names its own steps in prose ("Importing entries"); this recovers the
selection each one advances. Matched against the same __() calls the importer uses, so a
translated site matches on the translation rather than falling through.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$step | string | An import result's step value. |
Returns
string— A data-type id, or '' for a step that belongs to no single selection.
Since: %ver%
Source: src/DataTypes.php:197
for_import_phase()
public static function for_import_phase( string $phase ): string
The data type an importer phase advances, or '' for a phase that moves no selection.
The importer names its own finished phases in a result's data_status_completed, and
those names are internal: several of them advance one selection (views_fields,
views_form_id and views are all Views). Reading that list is what lets a summary
report Posts, which no step label names on its own -- the only label covering posts also
covers Views, so deriving from labels reports Views and silently drops every page, post
and custom post type the run moved.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$phase | string | A data_status_completed entry. |
Returns
string— A data-type id, or '' for a phase belonging to no selection.
Since: %ver%
Source: src/DataTypes.php:262
for_import_phases()
public static function for_import_phases( array $completed_phases ): array
The selections an importer result reports as finished.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$completed_phases | array | A result's data_status_completed list. |
Returns
string[]— Data-type ids, in phase order, each named once.
Since: %ver%
Source: src/DataTypes.php:299
summary()
public static function summary( array $data_types, array $rows=[] ): array
The data types a finished migration moved, ready to render.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$data_types | array | Data-type ids, in the order the run finished them. | |
$rows | array | [] | Optional id => row count. A type absent here reports null rather than 0, so "not counted" and "counted none" stay distinguishable. |
Returns
array<int,array{id:— string, label: string, rows: int|null}>
Since: %ver%
Source: src/DataTypes.php:326
mark_completed()
public static function mark_completed( array $completed, string $data_type ): array
Adds a data type to a completed list, in the order the run finished them.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$completed | array | Data-type ids finished so far. | |
$data_type | string | The type the run has just moved off, or '' for none. |
Returns
string[]— The list, unchanged when there is nothing to add.
Since: %ver%
Source: src/DataTypes.php:358