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
| Property | Type | Description |
|---|---|---|
$extensions | array<string, | array<string, mixed>> |
Methods
| Method | Description |
|---|---|
__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
| Name | Type | Default | Description |
|---|---|---|---|
$extensions | array | [] | 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
| Name | Type | Default | Description |
|---|---|---|---|
$platform | string | Platform identifier. | |
$data | array | Extension 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
| Name | Type | Default | Description |
|---|---|---|---|
$platform | string | Platform 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
| Name | Type | Default | Description |
|---|---|---|---|
$platform | string | Platform 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
| Name | Type | Default | Description |
|---|---|---|---|
$platform | string | Platform identifier. | |
$key | string | Extension key. | |
$value | mixed | Extension 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
| Name | Type | Default | Description |
|---|---|---|---|
$platform | string | Platform identifier. | |
$key | string | Extension key. | |
$default | mixed | null | Default 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
| Name | Type | Default | Description |
|---|---|---|---|
$platform | string | Platform identifier. | |
$key | string | Extension 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
| Name | Type | Default | Description |
|---|---|---|---|
$platform | string | Platform identifier. | |
$key | string | Extension 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
| Name | Type | Default | Description |
|---|---|---|---|
$platform | string | Platform 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
| Name | Type | Default | Description |
|---|---|---|---|
$other | ExtensionData | Other extension bag. | |
$overwrite | bool | true | Whether 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
| Name | Type | Default | Description |
|---|---|---|---|
$data | array | Array 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