Skip to main content

GravityKit\GravityBoard\Card

Class Card

Handles card creation, validation, and data management for GravityBoard.

Since: 1.0.0

Source: src/Card.php:27

Details

  • Kind: class
  • Namespace: GravityKit\GravityBoard

Methods

MethodDescription
__construct()Card constructor.
get_id()Get card ID.
get()Get a data field value.
set()Set a data field value.
get_title()Get card title.
set_title()Set card title.
get_description()Get card description.
set_description()Set card description.
get_label()Get card label.
set_label()Set card label.
get_position()Get card position.
set_position()Set card position.
get_due_date()Get card due date.
set_due_date()Set card due date.
get_due_date_timestamp()Get card due date timestamp.
set_due_date_timestamp()Set card due date timestamp.
get_lane()Get card lane.
set_lane()Set card lane.
to_array()Convert card to array format.
create_from_request()Create a card from request data.
update_from_request()Update a card from request data.
build_data_from_entry()Build card data from entry.
is_read_only_field()Whether a Gravity Forms field is one the card API cannot write.
writes_lane_field()Whether a mapped card field would write the board's lane field.
get_lane_field_keys()The card field keys that would write the board's lane field.
get_read_only_field_keys()The mapped card field keys whose form field the card API cannot write.

Method Reference

__construct()

public function __construct( string $id='', array $data=[], ?Lane $lane=null, array $feed=[], array $form=[] )

Card constructor.

Parameters

NameTypeDefaultDescription
$idstring''The card ID.
$dataarray[]
$laneLane | nullnullThe card lane.
$feedFeedRow | array{}[]The feed data (optional, for operations).
$formarray[]

Since: 1.0

Source: src/Card.php:180

get_id()

public function get_id(): string

Get card ID.

Returns

  • string

Since: 1.0

Source: src/Card.php:211

get()

public function get( string $key, $default_value=null )

Get a data field value.

Parameters

NameTypeDefaultDescription
$keystringThe data key.
$default_valuestring | int | string[] | nullnullReturned when the key is unset.

Returns

  • string | int | string[] | null

Since: 1.0

Source: src/Card.php:225

set()

public function set( string $key, $value ): void

Set a data field value.

Parameters

NameTypeDefaultDescription
$keystringThe data key.
$valuestring | int | string[] | nullThe value to set.

Returns

  • void

Since: 1.0

Source: src/Card.php:237

get_title()

public function get_title(): string

Get card title.

Returns

  • string

Since: 1.0

Source: src/Card.php:248

set_title()

public function set_title( string $title ): void

Set card title.

Parameters

NameTypeDefaultDescription
$titlestringThe card title.

Returns

  • void

Since: 1.0

Source: src/Card.php:259

get_description()

public function get_description(): string

Get card description.

Returns

  • string

Since: 1.0

Source: src/Card.php:270

set_description()

public function set_description( string $description ): void

Set card description.

Parameters

NameTypeDefaultDescription
$descriptionstringThe card description.

Returns

  • void

Since: 1.0

Source: src/Card.php:281

get_label()

public function get_label(): string

Get card label.

Returns

  • string

Since: 1.0

Source: src/Card.php:292

set_label()

public function set_label( string $label ): void

Set card label.

Parameters

NameTypeDefaultDescription
$labelstringThe card label.

Returns

  • void

Since: 1.0

Source: src/Card.php:303

get_position()

public function get_position(): int

Get card position.

Returns

  • int

Since: 1.0

Source: src/Card.php:314

set_position()

public function set_position( int $position ): void

Set card position.

Parameters

NameTypeDefaultDescription
$positionintThe card position.

Returns

  • void

Since: 1.0

Source: src/Card.php:325

get_due_date()

public function get_due_date(): string

Get card due date.

Returns

  • string

Since: 1.0

Source: src/Card.php:336

set_due_date()

public function set_due_date( string $due_date ): void

Set card due date.

Parameters

NameTypeDefaultDescription
$due_datestringThe card due date.

Returns

  • void

Since: 1.0

Source: src/Card.php:347

get_due_date_timestamp()

public function get_due_date_timestamp(): ?int

Get card due date timestamp.

Returns

  • int | null

Since: 1.0

Source: src/Card.php:358

set_due_date_timestamp()

public function set_due_date_timestamp( ?int $timestamp ): void

Set card due date timestamp.

Parameters

NameTypeDefaultDescription
$timestampint | nullThe card due date timestamp.

Returns

  • void

Since: 1.0

Source: src/Card.php:369

get_lane()

public function get_lane(): ?Lane

Get card lane.

Returns

  • Lane | null

Since: 1.0

Source: src/Card.php:380

set_lane()

public function set_lane( ?Lane $lane ): void

Set card lane.

Parameters

NameTypeDefaultDescription
$laneLane | nullThe card lane.

Returns

  • void

Since: 1.0

Source: src/Card.php:391

to_array()

public function to_array(): array

Convert card to array format.

Returns

  • array<string, — string|int|string[]|null> The card: id, lane_value, and every key the card data holds.

Since: 1.0

Source: src/Card.php:402

create_from_request()

public static function create_from_request( WP_REST_Request $request, array $feed, int $lane_id, int $position )

Create a card from request data.

Parameters

NameTypeDefaultDescription
$requestWP_REST_RequestThe REST request.
$feedFeedRow | array{}The feed data.
$lane_idintThe lane ID.
$positionintThe position the editor sends (the lane's card count). The stored position is computed from the lane instead.

Returns

  • array<string, — mixed>|WP_Error|ErrorCollection The new entry, as GFAPI::get_entry() returns it; a WP_Error on failure; an ErrorCollection on validation failure.

Since: 1.0

Source: src/Card.php:422

update_from_request()

public static function update_from_request( WP_REST_Request $request, array $entry, array $feed )

Update a card from request data.

Parameters

NameTypeDefaultDescription
$requestWP_REST_RequestThe REST request.
$entryarray
$feedFeedRow | array{}The feed data.

Returns

  • array{changes: — string[], updated_entry: array<string, mixed>|WP_Error}|WP_Error The card field keys written and the re-read entry, or a WP_Error on failure.

Since: 1.0

Source: src/Card.php:549

build_data_from_entry()

public static function build_data_from_entry( array $entry, array $feed ): array

Build card data from entry.

Parameters

NameTypeDefaultDescription
$entryarray
$feedFeedRow | array{}The feed data.

Returns

  • array<string, — mixed> The card: id, title, description, label, position, due_date, due_date_timestamp, lane_value and choice_field_values, plus every other mapped field under its own key and whatever the card/data filter adds.

Since: 1.0

Source: src/Card.php:616

is_read_only_field()

public static function is_read_only_field( $field )

Whether a Gravity Forms field is one the card API cannot write.

Parameters

NameTypeDefaultDescription
$field\GF_Field | nullThe field.

Returns

  • bool

Since: 1.5.0

Source: src/Card.php:870

writes_lane_field()

public static function writes_lane_field( array $feed, string $field_key, $field_id ): bool

Whether a mapped card field would write the board's lane field.

The Label chooser offers select and radio and so does the Lane chooser, so a board can map another card field onto the very field that holds the lane. Writing it moves the card between lanes without gk/gravityboard/card/changed-lane firing or the lane positions being handled, which only the move endpoint does.

Parameters

NameTypeDefaultDescription
$feedFeedRow | array{}The feed.
$field_keystringThe card field key.
$field_idstring | intThe form field ID the key is mapped to, or '' when unmapped.

Returns

  • bool

Since: 1.5.0

Source: src/Card.php:890

get_lane_field_keys()

public static function get_lane_field_keys( array $feed ): array

The card field keys that would write the board's lane field.

Always holds lane_field itself, plus any other card field the board maps onto the same form field.

Parameters

NameTypeDefaultDescription
$feedFeedRow | array{}The feed.

Returns

  • string[] — Card field keys.

Since: 1.5.0

Source: src/Card.php:912

get_read_only_field_keys()

public static function get_read_only_field_keys( array $feed, $form ): array

The mapped card field keys whose form field the card API cannot write.

Parameters

NameTypeDefaultDescription
$feedFeedRow | array{}The feed.
$form

Returns

  • string[] — Card field keys.

Since: 1.5.0

Source: src/Card.php:934