class ContentType extends BaseResource implements ContentTypeInterface, CreatableInterface

ContentType class.

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

Traits

ContentTypeProxyExtension trait.
DeletableTrait.
PublishableTrait.
UpdatableTrait.

Properties

protected ContentType $sys
Client $client from UpdatableTrait
protected string $name
protected string|null $description
protected string|null $displayField
protected FieldInterface[] $fields
protected bool $isPublished

Methods

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.

getSpaceId()

{@inheritdoc}

getEnvironmentId()

{@inheritdoc}

getContentTypeId()

{@inheritdoc}

getSnapshot(string $snapshotId)

Returns a ContentTypeSnapshot resource.

getSnapshots(Query $query = null)

Returns a ResourceArray object which contains ContentTypeSnapshot resources.

getEditorInterface()

Returns an EditorInterface resource.

delete()

Deletes the current resource.

publish()

Publishes the current resource.

unpublish()

Unpublishes the current resource.

getSystemProperties()

{@inheritdoc}

update()

Updates the current resource.

__construct(string $name)

ContentType constructor.

jsonSerialize()

{@inheritdoc}

string[]
asUriParameters()

Returns an associative 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.

getName()

No description

setName(string $name)

No description

string|null
getDescription()

No description

setDescription(string $description = null)

No description

string|null
getDisplayField()

No description

setDisplayField(string $displayField = null)

No description

getFields()

No description

getField(string $fieldId)

No description

setFields(array $fields)

No description

addField(FieldInterface $contentTypeField)

No description

isPublished()

No description

addNewField(string $type, string $fieldId, string $name, array $params)

Adds a new content type field, and returns it.

createField(string $type, string $fieldId, string $name, array $params)

Shortcut for creating a new field object.

Details

in BaseResource at line 37
getId()

{@inheritdoc}

in BaseResource at line 45
getType()

{@inheritdoc}

{@inheritdoc}

in UpdatableTrait at line 35
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 77
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

at line 131
protected getSpaceId()

{@inheritdoc}

at line 139
protected getEnvironmentId()

{@inheritdoc}

at line 147
protected getContentTypeId()

{@inheritdoc}

getSnapshot(string $snapshotId)

Returns a ContentTypeSnapshot resource.

Parameters

string $snapshotId

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/snapshots/content-type-snapshot

getSnapshots(Query $query = null)

Returns a ResourceArray object which contains ContentTypeSnapshot resources.

Parameters

Query $query

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/snapshots/content-type-snapshots-collection

getEditorInterface()

Returns an EditorInterface resource.

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/editor-interface

in DeletableTrait at line 28
delete()

Deletes the current resource.

in PublishableTrait at line 31
publish()

Publishes the current resource.

in PublishableTrait at line 41
unpublish()

Unpublishes the current resource.

at line 81
getSystemProperties()

{@inheritdoc}

in UpdatableTrait at line 40
update()

Updates the current resource.

at line 73
__construct(string $name)

ContentType constructor.

Parameters

string $name

at line 89
jsonSerialize()

{@inheritdoc}

at line 111
string[] asUriParameters()

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

Return Value

string[]

at line 123
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 152
getName()

at line 160
ContentType setName(string $name)

Parameters

string $name

Return Value

ContentType

at line 170
string|null getDescription()

Return Value

string|null

at line 178
ContentType setDescription(string $description = null)

Parameters

string $description

Return Value

ContentType

at line 188
string|null getDisplayField()

Return Value

string|null

at line 196
ContentType setDisplayField(string $displayField = null)

Parameters

string $displayField

Return Value

ContentType

at line 206
FieldInterface[] getFields()

Return Value

FieldInterface[]

at line 214
getField(string $fieldId)

Parameters

string $fieldId

Exceptions

InvalidArgumentException

at line 230
ContentType setFields(array $fields)

Parameters

array $fields

Return Value

ContentType

at line 240
ContentType addField(FieldInterface $contentTypeField)

Parameters

FieldInterface $contentTypeField

Return Value

ContentType

at line 247
isPublished()

at line 260
addNewField(string $type, string $fieldId, string $name, array $params)

Adds a new content type field, and returns it.

Parameters

string $type A valid field type, must be a class in the Contentful\Management\Resource\ContentType\Field namespace
string $fieldId The field ID
string $name The field name
array $params mixed> $params Extra parameters that will be forwarded to the field object constructor

at line 276
createField(string $type, string $fieldId, string $name, array $params)

Shortcut for creating a new field object.

Parameters

string $type A valid field type, must be a class in the Contentful\Management\Resource\ContentType\Field namespace
string $fieldId The field ID
string $name The field name
array $params mixed> $params Extra parameters that will be forwarded to the field object constructor