class ResourceTypeRelationship extends 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.
 

Specialization of a ResourceTypeField to represent a resource relationship.

Properties

protected string $internalName

The internal field name.

from  ResourceTypeField
protected string $publicName

The public field name.

from  ResourceTypeField
protected bool $enabled

Whether the field is disabled.

from  ResourceTypeField
protected bool $hasOne

Whether the field can only have one value.

from  ResourceTypeField
protected ResourceType[] $relatableResourceTypes

The resource type to which this relationships can relate.

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.

withRelatableResourceTypes(array $resource_types)

Establishes the relatable resource types of this field.

getRelatableResourceTypes()

Gets the relatable resource types.

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.

ResourceTypeRelationship withRelatableResourceTypes(array $resource_types)

Establishes the relatable resource types of this field.

Parameters

array $resource_types

The array of relatable resource types.

Return Value

ResourceTypeRelationship

A new instance of the field with the given relatable resource types.

ResourceType[] getRelatableResourceTypes()

Gets the relatable resource types.

Return Value

ResourceType[]

The resource type to which this relationships can relate.