GravityKit\GravityCalendar\Abilities\Support\SettingsCatalog
The calendar settings as abilities see them: one key per feed meta key, typed, with its
default and its valid values.
Keys are the feed meta keys the settings screen saves, so gc_calendar_get returns what is
stored and gc_calendar_update writes it back. Choice lists, field types and defaults are
read from GV_Extension_Calendar_Feed::feed_settings_fields() at call time, so they cannot
disagree with the screen. A drift test fails when the screen gains a setting this does not list.
Since: TBD
Source: includes/abilities/Support/SettingsCatalog.php:32
Details
- Kind:
class - Namespace:
GravityKit\GravityCalendar\Abilities\Support
Methods
| Method | Description |
|---|---|
reset() | Forgets the settings screen's fields, so the next read builds them again. |
screen_fields() | The fields of the settings screen, flattened, keyed by stored meta key. |
definitions() | Every setting, keyed by meta key. |
allowed_values() | The values an enum setting accepts, from the settings screen's own choices. |
role_values() | The roles editroles accepts. |
field_types() | The field types a field setting accepts, from the screen's field_select arguments. |
eligible_fields() | The form fields a field setting may name, as the settings screen lists them. |
screen_field_defaults() | The fields the settings screen selects on a new calendar, by matching labels. |
notification_choices() | The active notifications of a form, which calendarNotification may name. |
from_meta() | The stored settings in the shape gc_calendar_get returns and gc_calendar_update accepts. |
default_meta() | The meta a new calendar starts from: every setting at the default the settings screen |
property_schema() | JSON Schema for one setting, in the output shape. |
settings_schema() | JSON Schema of the settings object. |
required_on_create() | The settings a new calendar cannot be saved without. |
with_subscription_url() | Gives a calendar a subscription link when it has none, as saving the settings screen does. |
from_input() | The settings an ability was sent, as a plain array with their booleans as booleans. |
normalize() | Sent settings with their booleans as booleans. |
to_meta() | Merges changed settings into a feed's meta, checking each the way the settings screen does. |
Method Reference
reset()
public static function reset(): void
Forgets the settings screen's fields, so the next read builds them again.
For tests that change them with a filter mid-request.
Returns
void
Since: TBD
Source: includes/abilities/Support/SettingsCatalog.php:144
screen_fields()
public static function screen_fields(): array
The fields of the settings screen, flattened, keyed by stored meta key.
A checkbox group is listed under each choice's name, since that is what it stores. Built
once per request: one ability call reads them dozens of times, and each build reads every
locale and View. Nothing an ability writes changes them.
Returns
array<string,— array> Meta key => the screen's field definition.
Since: TBD
Source: includes/abilities/Support/SettingsCatalog.php:159
definitions()
public static function definitions(): array
Every setting, keyed by meta key.
Each row: kind (how it is typed and checked), description, default (what the screen
gives a new calendar, in the shape gc_calendar_get returns), required_on_create,
depends_on where the screen hides it, and when_missing (what the calendar does when the
setting has no stored meta).
Returns
array<string,— array{kind:string, description:string, default:mixed, required_on_create:bool, depends_on:string, when_missing:mixed}>
Since: TBD
Source: includes/abilities/Support/SettingsCatalog.php:206
allowed_values()
public static function allowed_values( string $key, array $form=[] ): array
The values an enum setting accepts, from the settings screen's own choices.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$key | string | The setting. | |
$form | array | [] | The calendar's form. Without one, eventurlentry offers no View. |
Returns
string[]
Since: TBD The settings screen lists the Views for eventurlentry from the form it is open on. Ability calls never open it, so those choices are built here from the form given.
Source: includes/abilities/Support/SettingsCatalog.php:469
role_values()
public static function role_values(): array
The roles editroles accepts.
Returns
string[]
Since: TBD
Source: includes/abilities/Support/SettingsCatalog.php:543
field_types()
public static function field_types( string $key ): array
The field types a field setting accepts, from the screen's field_select arguments.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$key | string | The setting. |
Returns
string[]
Since: TBD
Source: includes/abilities/Support/SettingsCatalog.php:556
eligible_fields()
public static function eligible_fields( array $form, string $key ): array
The form fields a field setting may name, as the settings screen lists them.
Mirrors Gravity_Forms\Gravity_Forms\Settings\Fields\Field_Select::get_form_fields_as_choices(),
which Gravity Forms builds only on the settings screen, where its renderer exists. The entry
date and time choices GV_Extension_Calendar_Feed::get_form_fields_as_choices() adds are left
out: Field_Select never calls it, so the screen does not offer them, and a calendar mapped
to one opens with nothing selected. A calendar that already stores one keeps it, since
\self::to_meta() skips a value that has not changed.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The form. | |
$key | string | The setting. |
Returns
array<int,— array{id:string, label:string, type:string}>
Since: TBD
Source: includes/abilities/Support/SettingsCatalog.php:579
screen_field_defaults()
public static function screen_field_defaults( array $form ): array
The fields the settings screen selects on a new calendar, by matching labels.
Mirrors Gravity_Forms\Gravity_Forms\Settings\Fields\Field_Select::get_default_choice():
a field setting with no fixed default selects the first field whose label matches the
setting's label, ignoring case, so a form with an "End Time" field gets it as End Time.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The form. |
Returns
array<string,— string> Setting => field id.
Since: TBD
Source: includes/abilities/Support/SettingsCatalog.php:635
notification_choices()
public static function notification_choices( array $form ): array
The active notifications of a form, which calendarNotification may name.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The form. |
Returns
array<string,— string> Notification id => name.
Since: TBD
Source: includes/abilities/Support/SettingsCatalog.php:675
from_meta()
public static function from_meta( array $meta ): array
The stored settings in the shape gc_calendar_get returns and gc_calendar_update accepts.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$meta | array | The feed meta. |
Returns
array<string,— mixed>
Since: TBD
Source: includes/abilities/Support/SettingsCatalog.php:698
default_meta()
public static function default_meta(): array
The meta a new calendar starts from: every setting at the default the settings screen
shows on a new calendar, in stored form.
Returns
array
Since: TBD
Source: includes/abilities/Support/SettingsCatalog.php:780
property_schema()
public static function property_schema( string $key, array $definition ): array
JSON Schema for one setting, in the output shape.
Valid values are named in the description and checked in \self::to_meta() rather than
declared as an enum: a stored legacy value must still read back without failing the call.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$key | string | The setting. | |
$definition | array | Its definition. |
Returns
array
Since: TBD
Source: includes/abilities/Support/SettingsCatalog.php:817
settings_schema()
public static function settings_schema( string $description='' ): array
JSON Schema of the settings object.
The same schema is gc_calendar_get's output and gc_calendar_update's input, which is
what lets a read be sent back unchanged.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$description | string | '' | What the object is in this ability. Default: the settings as stored. |
Returns
array
Since: TBD
Source: includes/abilities/Support/SettingsCatalog.php:904
required_on_create()
public static function required_on_create(): array
The settings a new calendar cannot be saved without.
Returns
string[]
Since: TBD
Source: includes/abilities/Support/SettingsCatalog.php:939
with_subscription_url()
public static function with_subscription_url( array $meta ): array
Gives a calendar a subscription link when it has none, as saving the settings screen does.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$meta | array | Feed meta. |
Returns
array
Since: TBD
Source: includes/abilities/Support/SettingsCatalog.php:952
from_input()
public static function from_input( array $input ): array
The settings an ability was sent, as a plain array with their booleans as booleans.
Foundation can hand a JSON object over as stdClass; a round trip through JSON turns it, and
anything nested in it, into arrays.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$input | array | Ability input. |
Returns
array
Since: TBD
Source: includes/abilities/Support/SettingsCatalog.php:980
normalize()
public static function normalize( array $settings ): array
Sent settings with their booleans as booleans.
WordPress passes "false" through its boolean check unconverted, and it is truthy in PHP; run
this before any check or comparison.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$settings | array | Settings as sent. |
Returns
array
Since: TBD
Source: includes/abilities/Support/SettingsCatalog.php:1000
to_meta()
public static function to_meta( array $settings, array $meta, array $form )
Merges changed settings into a feed's meta, checking each the way the settings screen does.
Only the keys present in $settings change; a value equal to what is stored is left alone
without being checked again, so gc_calendar_get's output can be sent back unchanged even
when it holds a value the screen would no longer accept.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$settings | array | Changed settings, in the shape \self::from_meta() returns. | |
$meta | array | The stored meta, or the defaults for a new calendar. | |
$form | array | The calendar's form. |
Returns
array| WP_Error — The new meta.
Since: TBD
Source: includes/abilities/Support/SettingsCatalog.php:1062