abstract class ResourceTypeField (View source)

internal  JSON:API maintains no PHP API since its API is the HTTP API. This class may change at any time and this will break any dependencies on it.
 

Abstract value object containing all metadata for a JSON:API resource field.

Properties

protected string $internalName

The internal field name.

protected string $publicName

The public field name.

protected bool $enabled

Whether the field is disabled.

protected bool $hasOne

Whether the field can only have one value.

Methods

__construct(string $internal_name, string $public_name = NULL, bool $enabled = TRUE, bool $has_one = TRUE)

ResourceTypeField constructor.

string
getInternalName()

Gets the internal name of the field.

string
getPublicName()

Gets the public name of the field.

withPublicName(string $public_name)

Establishes a new public name for the field.

disabled()

Gets a new instance of the field that is disabled.

bool
isFieldEnabled()

Whether the field is enabled.

bool
hasOne()

Whether the field can only have one value.

bool
hasMany()

Whether the field can have many values.

Details

__construct(string $internal_name, string $public_name = NULL, bool $enabled = TRUE, bool $has_one = TRUE)

ResourceTypeField constructor.

Parameters

string $internal_name

The internal field name.

string $public_name

(optional) The public field name. Defaults to the internal field name.

bool $enabled

(optional) Whether the field is enabled. Defaults to TRUE.

bool $has_one

(optional) Whether the field can only have ony value. Defaults to TRUE.

string getInternalName()

Gets the internal name of the field.

Return Value

string

The internal name of the field.

string getPublicName()

Gets the public name of the field.

Return Value

string

The public name of the field.

ResourceTypeField withPublicName(string $public_name)

Establishes a new public name for the field.

Parameters

string $public_name

The public name.

Return Value

ResourceTypeField

A new instance of the field with the given public name.

ResourceTypeField disabled()

Gets a new instance of the field that is disabled.

Return Value

ResourceTypeField

A new instance of the field that is disabled.

bool isFieldEnabled()

Whether the field is enabled.

Return Value

bool

Whether the field is enabled. FALSE if the field should not be in the JSON:API response.

bool hasOne()

Whether the field can only have one value.

Return Value

bool

TRUE if the field can have only one value, FALSE otherwise.

bool hasMany()

Whether the field can have many values.

Return Value

bool

TRUE if the field can have more than one value, FALSE otherwise.