class Asset extends BaseResource implements CreatableInterface

Asset class.

This class represents a resource with type "Asset" in Contentful.

Traits

ArchivableTrait.
DeletableTrait.
PublishableTrait.
UpdatableTrait.

Properties

SystemProperties $sys from UpdatableTrait
Client $client from UpdatableTrait
protected string[] $title
protected string[] $description
protected FileInterface[] $file

Methods

initialize(string $type, array $sys = [])

Initialize system properties.

getSystemProperties()

{@inheritdoc}

getId()

{@inheritdoc}

getType()

{@inheritdoc}

asLink()

{@inheritdoc}

mixed
asRequestBody()

Returns the resource in the form of request body.

setClient(Client $client)

Sets the current Client object instance.

archive()

Archives the current resource.

unarchive()

Unarchives the current resource.

delete()

Deletes the current resource.

publish()

Publishes the current resource.

unpublish()

Unpublishes the current resource.

update()

Deletes the current resource.

__construct()

Asset constructor.

array
jsonSerialize()

Returns an array to be used by "json_encode" to serialize objects of this class.

string[]
asUriParameters()

Returns an associate array where keys are the name of the fragments in a URI, and the values are the corresponding IDs.

string[]
getHeadersForCreation()

Returns an array of headers that the current resource needs to sent for being created.

process(string $locale = null)

Call the endpoint for processing the file associated to the asset.

string|null
getTitle(string $locale)

No description

setTitle(string $locale, string $title = null)

No description

string[]
getTitles()

No description

string|null
getDescription(string $locale)

No description

setDescription(string $locale, string $description = null)

No description

string[]
getDescriptions()

No description

FileInterface|null
getFile(string $locale)

No description

setFile(string $locale, UnprocessedFileInterface $file = null)

No description

FileInterface[]
getFiles()

No description

Details

in BaseResource at line 39
protected initialize(string $type, array $sys = [])

Initialize system properties.

Parameters

string $type The system type
array $sys

in BaseResource at line 48
getSystemProperties()

{@inheritdoc}

in BaseResource at line 56
getId()

{@inheritdoc}

in BaseResource at line 64
getType()

{@inheritdoc}

{@inheritdoc}

in UpdatableTrait at line 33
abstract mixed asRequestBody()

Returns the resource in the form of request body.

This can differ from regular serialization, as some fields may not be present in the request payload.

Return Value

mixed

in BaseResource at line 98
BaseResource setClient(Client $client)

Sets the current Client object instance.

This is done automatically when performing API calls, so it shouldn't be used manually.

Parameters

Client $client

Return Value

BaseResource

in ArchivableTrait at line 29
archive()

Archives the current resource.

in ArchivableTrait at line 39
unarchive()

Unarchives the current resource.

in DeletableTrait at line 29
delete()

Deletes the current resource.

in PublishableTrait at line 29
publish()

Publishes the current resource.

in PublishableTrait at line 39
unpublish()

Unpublishes the current resource.

in UpdatableTrait at line 38
update()

Deletes the current resource.

at line 53
__construct()

Asset constructor.

at line 63
array jsonSerialize()

Returns an array to be used by "json_encode" to serialize objects of this class.

Return Value

array

at line 88
string[] asUriParameters()

Returns an associate array where keys are the name of the fragments in a URI, and the values are the corresponding IDs.

Return Value

string[]

at line 100
string[] getHeadersForCreation()

Returns an array of headers that the current resource needs to sent for being created.

This method is supposed to be overridden if necessary.

Return Value

string[]

at line 112
process(string $locale = null)

Call the endpoint for processing the file associated to the asset.

Parameters

string $locale

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/assets/asset-processing

at line 132
string|null getTitle(string $locale)

Parameters

string $locale

Return Value

string|null

at line 147
Asset setTitle(string $locale, string $title = null)

Parameters

string $locale
string $title

Return Value

Asset

at line 157
string[] getTitles()

Return Value

string[]

at line 167
string|null getDescription(string $locale)

Parameters

string $locale

Return Value

string|null

at line 182
Asset setDescription(string $locale, string $description = null)

Parameters

string $locale
string $description

Return Value

Asset

at line 192
string[] getDescriptions()

Return Value

string[]

at line 202
FileInterface|null getFile(string $locale)

Parameters

string $locale

Return Value

FileInterface|null

at line 217
Asset setFile(string $locale, UnprocessedFileInterface $file = null)

Parameters

string $locale
UnprocessedFileInterface $file

Return Value

Asset

at line 227
FileInterface[] getFiles()

Return Value

FileInterface[]