class ContentType extends BaseResource implements CreatableInterface

ContentType class.

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

Traits

ContentTypeProxyExtension trait.
DeletableTrait.
PublishableTrait.
UpdatableTrait.

Properties

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

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.

getSpaceId()

{@inheritdoc}

getEnvironmentId()

{@inheritdoc}

getContentTypeId()

{@inheritdoc}

getSnapshot(string $snapshotId)

Returns a ContentTypeSnapshot resource.

ResourceArray
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.

update()

Deletes the current resource.

__construct(string $name)

ContentType 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.

string
getName()

No description

setName(string $name = null)

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

bool
isPublished()

No description

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

Adds a new content type field, and returns it.

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

Shortcut for creating a new field object.

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

at line 118
protected getSpaceId()

{@inheritdoc}

at line 126
protected getEnvironmentId()

{@inheritdoc}

at line 134
protected getContentTypeId()

{@inheritdoc}

ContentTypeSnapshot getSnapshot(string $snapshotId)

Returns a ContentTypeSnapshot resource.

Parameters

string $snapshotId

Return Value

ContentTypeSnapshot

See also

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

ResourceArray getSnapshots(Query $query = null)

Returns a ResourceArray object which contains ContentTypeSnapshot resources.

Parameters

Query $query

Return Value

ResourceArray

See also

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

EditorInterface getEditorInterface()

Returns an EditorInterface resource.

Return Value

EditorInterface

See also

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

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 65
__construct(string $name)

ContentType constructor.

Parameters

string $name

at line 76
array jsonSerialize()

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

Return Value

array

at line 98
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 110
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 142
string getName()

Return Value

string

at line 152
ContentType setName(string $name = null)

Parameters

string $name

Return Value

ContentType

at line 162
string|null getDescription()

Return Value

string|null

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

Parameters

string $description

Return Value

ContentType

at line 182
string|null getDisplayField()

Return Value

string|null

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

Parameters

string $displayField

Return Value

ContentType

at line 202
FieldInterface[] getFields()

Return Value

FieldInterface[]

at line 214
FieldInterface getField(string $fieldId)

Parameters

string $fieldId

Return Value

FieldInterface

Exceptions

InvalidArgumentException

at line 234
ContentType setFields(array $fields)

Parameters

array $fields

Return Value

ContentType

at line 246
ContentType addField(FieldInterface $contentTypeField)

Parameters

FieldInterface $contentTypeField

Return Value

ContentType

at line 256
bool isPublished()

Return Value

bool

at line 271
FieldInterface addNewField(string $type, string $fieldId, string $name, mixed $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
mixed $params Extra parameters that will be forwarded to the field object constructor

Return Value

FieldInterface

at line 289
FieldInterface createField(string $type, string $fieldId, string $name, mixed $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
mixed $params Extra parameters that will be forwarded to the field object constructor

Return Value

FieldInterface