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

string
getId()

{@inheritdoc}

string
getType()

{@inheritdoc}

Link
asLink()

{@inheritdoc}

mixed
asRequestBody()

Returns the resource in the form of request body.

setClient(Client $client)

Sets the current Client object instance.

string
getSpaceId()

{@inheritdoc}

string
getEnvironmentId()

{@inheritdoc}

string
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()

Updates the current resource.

__construct(string $name)

ContentType constructor.

array
jsonSerialize()

{@inheritdoc}

array
asUriParameters()

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

array
getHeadersForCreation()

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

string
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

array
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, 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
string getId()

{@inheritdoc}

Return Value

string

in BaseResource at line 45
string getType()

{@inheritdoc}

Return Value

string

{@inheritdoc}

Return Value

Link

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 79
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 string getSpaceId()

{@inheritdoc}

Return Value

string

at line 139
protected string getEnvironmentId()

{@inheritdoc}

Return Value

string

at line 147
protected string getContentTypeId()

{@inheritdoc}

Return Value

string

ContentTypeSnapshot getSnapshot(string $snapshotId)

Returns a ContentTypeSnapshot resource.

ResourceArray getSnapshots(Query $query = \null)

Returns a ResourceArray object which contains ContentTypeSnapshot resources.

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
ContentType getSystemProperties()

{@inheritdoc}

Return Value

ContentType

in UpdatableTrait at line 40
update()

Updates the current resource.

at line 73
__construct(string $name)

ContentType constructor.

Parameters

string $name

at line 89
array jsonSerialize()

{@inheritdoc}

Return Value

array

at line 111
array 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

array

at line 123
array 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

array

at line 155
string getName()

Return Value

string

at line 165
ContentType setName(string $name)

Parameters

string $name

Return Value

ContentType

at line 175
string|null getDescription()

Return Value

string|null

at line 185
ContentType setDescription(string $description = \null)

Parameters

string $description

Return Value

ContentType

at line 195
string|null getDisplayField()

Return Value

string|null

at line 205
ContentType setDisplayField(string $displayField = \null)

Parameters

string $displayField

Return Value

ContentType

at line 215
array getFields()

Return Value

array

at line 227
FieldInterface getField(string $fieldId)

Parameters

string $fieldId

Return Value

FieldInterface

Exceptions

InvalidArgumentException

at line 247
ContentType setFields(array $fields)

Parameters

array $fields

Return Value

ContentType

at line 259
ContentType addField(FieldInterface $contentTypeField)

Parameters

FieldInterface $contentTypeField

Return Value

ContentType

at line 269
bool isPublished()

Return Value

bool

at line 284
FieldInterface 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

Return Value

FieldInterface

at line 302
FieldInterface 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

Return Value

FieldInterface