Skip to main content

GravityKit\GravityMigrate\Schema\ExtensionData

Stores platform-specific extensions that don't map to universal properties.

Anything a form plugin keeps that the universal schema cannot represent is held here so it survives the trip. Extensions are namespaced by platform, so two platforms using the same key name do not collide.

Since: %ver%

Source: src/Schema/ExtensionData.php:19

Details

  • Kind: class

  • Namespace: GravityKit\GravityMigrate\Schema

  • Implements: ArrayAccess, JsonSerializable

Properties

PropertyTypeDescription
$extensionsarray<string,array<string, mixed>>

Methods

MethodDescription
__construct()Constructor.
set_platform_data()Sets all extensions for a platform.
get_platform_data()Gets all extensions for a platform.
has_platform()Checks if extensions exist for a platform.
set()Sets a single extension value.
get()Gets a single extension value.
has()Checks if a specific extension exists.
remove()Removes a specific extension.
remove_platform()Removes all extensions for a platform.
merge()Merges another ExtensionData into this one.
all()Returns all extensions.
get_platforms()Returns list of platforms with extensions.
is_empty()Checks if the bag is empty.
clear()Clears all extensions.
from_array()Creates an ExtensionData from an array.
to_array()Converts to array.

Method Reference

__construct()

public function __construct( array $extensions=[] )

Constructor.

Parameters

NameTypeDefaultDescription
$extensionsarray[]Initial extensions keyed by platform.

Since: %ver%

Source: src/Schema/ExtensionData.php:51

set_platform_data()

public function set_platform_data( string $platform, array $data ): self

Sets all extensions for a platform.

Parameters

NameTypeDefaultDescription
$platformstringPlatform identifier.
$dataarrayExtension data.

Returns

  • self

Since: %ver%

Source: src/Schema/ExtensionData.php:67

get_platform_data()

public function get_platform_data( string $platform ): array

Gets all extensions for a platform.

Parameters

NameTypeDefaultDescription
$platformstringPlatform identifier.

Returns

  • array

Since: %ver%

Source: src/Schema/ExtensionData.php:82

has_platform()

public function has_platform( string $platform ): bool

Checks if extensions exist for a platform.

Parameters

NameTypeDefaultDescription
$platformstringPlatform identifier.

Returns

  • bool

Since: %ver%

Source: src/Schema/ExtensionData.php:95

set()

public function set( string $platform, string $key, $value ): self

Sets a single extension value.

Parameters

NameTypeDefaultDescription
$platformstringPlatform identifier.
$keystringExtension key.
$valuemixedExtension value.

Returns

  • self

Since: %ver%

Source: src/Schema/ExtensionData.php:110

get()

public function get( string $platform, string $key, $default=null )

Gets a single extension value.

Parameters

NameTypeDefaultDescription
$platformstringPlatform identifier.
$keystringExtension key.
$defaultmixednullDefault value if not found.

Returns

  • mixed

Since: %ver%

Source: src/Schema/ExtensionData.php:131

has()

public function has( string $platform, string $key ): bool

Checks if a specific extension exists.

Parameters

NameTypeDefaultDescription
$platformstringPlatform identifier.
$keystringExtension key.

Returns

  • bool

Since: %ver%

Source: src/Schema/ExtensionData.php:145

remove()

public function remove( string $platform, string $key ): self

Removes a specific extension.

Parameters

NameTypeDefaultDescription
$platformstringPlatform identifier.
$keystringExtension key.

Returns

  • self

Since: %ver%

Source: src/Schema/ExtensionData.php:159

remove_platform()

public function remove_platform( string $platform ): self

Removes all extensions for a platform.

Parameters

NameTypeDefaultDescription
$platformstringPlatform identifier.

Returns

  • self

Since: %ver%

Source: src/Schema/ExtensionData.php:174

merge()

public function merge( ExtensionData $other, bool $overwrite=true ): self

Merges another ExtensionData into this one.

Parameters

NameTypeDefaultDescription
$otherExtensionDataOther extension bag.
$overwritebooltrueWhether the other bag's values win where both hold the same platform and key. When false, the values already here win.

Returns

  • self

Since: %ver%

Source: src/Schema/ExtensionData.php:191

all()

public function all(): array

Returns all extensions.

Returns

  • array<string, — array<string, mixed>>

Since: %ver%

Source: src/Schema/ExtensionData.php:212

get_platforms()

public function get_platforms(): array

Returns list of platforms with extensions.

Returns

  • array<string>

Since: %ver%

Source: src/Schema/ExtensionData.php:223

is_empty()

public function is_empty(): bool

Checks if the bag is empty.

Returns

  • bool

Since: %ver%

Source: src/Schema/ExtensionData.php:234

clear()

public function clear(): self

Clears all extensions.

Returns

  • self

Since: %ver%

Source: src/Schema/ExtensionData.php:245

from_array()

public static function from_array( array $data ): self

Creates an ExtensionData from an array.

Parameters

NameTypeDefaultDescription
$dataarrayArray data.

Returns

  • self

Since: %ver%

Source: src/Schema/ExtensionData.php:260

to_array()

public function to_array(): array

Converts to array.

Returns

  • array

Since: %ver%

Source: src/Schema/ExtensionData.php:271