class ResourceTypeBuildEvent extends Event (View source)

An event used to configure the construction of a JSON:API resource type.

Properties

protected string $resourceTypeName

The JSON:API resource type name of the instance to be built.

protected ResourceTypeField[] $fields

The fields of the resource type to be built.

protected bool $disabled

Whether the JSON:API resource type to be built should be disabled.

Methods

__construct(string $resource_type_name, array $fields)

ResourceTypeBuildEvent constructor.

createFromEntityTypeAndBundle(EntityTypeInterface $entity_type, string $bundle, array $fields)

Creates a new ResourceTypeBuildEvent.

string
getResourceTypeName()

Gets current resource type name of the resource type to be built.

disableResourceType()

Disables the resource type to be built.

bool
resourceTypeShouldBeDisabled()

Whether the resource type to be built should be disabled.

getFields()

Gets the current fields of the resource type to be built.

setPublicFieldName(ResourceTypeField $field, string $public_field_name)

Sets the public name of the given field on the resource type to be built.

disableField(ResourceTypeField $field)

Disables the given field on the resource type to be built.

Details

protected __construct(string $resource_type_name, array $fields)

ResourceTypeBuildEvent constructor.

This constructor is protected by design. Use static::createFromEntityTypeAndBundle() instead.

Parameters

string $resource_type_name

A JSON:API resource type name.

array $fields

The fields of the resource type to be built.

static ResourceTypeBuildEvent createFromEntityTypeAndBundle(EntityTypeInterface $entity_type, string $bundle, array $fields)

Creates a new ResourceTypeBuildEvent.

Parameters

EntityTypeInterface $entity_type

An entity type for the resource type to be built.

string $bundle

A bundle name for the resource type to be built. If the entity type does not have bundles, the entity type ID.

array $fields

The fields of the resource type to be built.

Return Value

ResourceTypeBuildEvent

A new event.

string getResourceTypeName()

Gets current resource type name of the resource type to be built.

Return Value

string

The resource type name.

disableResourceType()

Disables the resource type to be built.

bool resourceTypeShouldBeDisabled()

Whether the resource type to be built should be disabled.

Return Value

bool

TRUE if the resource type should be disabled, FALSE otherwise.

ResourceTypeField[] getFields()

Gets the current fields of the resource type to be built.

Return Value

ResourceTypeField[]

The current fields of the resource type to be built.

setPublicFieldName(ResourceTypeField $field, string $public_field_name)

Sets the public name of the given field on the resource type to be built.

Parameters

ResourceTypeField $field

The field for which to set a public name.

string $public_field_name

The public field name to set.

disableField(ResourceTypeField $field)

Disables the given field on the resource type to be built.

Parameters

ResourceTypeField $field

The field for which to set a public name.