Copied!

ContentTypeService

ContentTypeService.php : 23

Methods

publicaddFieldDefinition()

ContentTypeService.php : 283

Adds a new field definition to an existing content type.

public addFieldDefinition(ContentTypeDraft $contentTypeDraft, FieldDefinitionCreateStruct $fieldDefinitionCreateStruct) : void

The content type must be in state DRAFT.

Parameters

Name Type Default value Description
$contentTypeDraft ContentTypeDraft - -
$fieldDefinitionCreateStruct FieldDefinitionCreateStruct - -
Tags
Throws
InvalidArgumentException

if the identifier in already exists in the content type

Throws
UnauthorizedException

if the user is not allowed to edit a content type

Throws
ContentTypeFieldDefinitionValidationException

if a field definition in the $contentTypeCreateStruct is not valid

Throws
BadStateException

If field definition of the same non-repeatable type is being added to the ContentType that already contains one or field definition that can't be added to a ContentType that has Content instances is being added to such ContentType

publicassignContentTypeGroup()

ContentTypeService.php : 252

Assigns a content type to a content type group.

public assignContentTypeGroup(ContentType $contentType, ContentTypeGroup $contentTypeGroup) : void

Parameters

Name Type Default value Description
$contentType ContentType - -
$contentTypeGroup ContentTypeGroup - -
Tags
Throws
UnauthorizedException

if the user is not allowed to unlink a content type

Throws
InvalidArgumentException

If the content type is already assigned the given group

publiccopyContentType()

ContentTypeService.php : 241

Copy Type incl fields and groupIds to a new Type object.

public copyContentType(ContentType $contentType[, User $creator = null ]) : ContentType

New Type will have $creator as creator / modifier, created / modified should be updated with current time, updated remoteId and identifier should be appended with '_' + unique string.

Parameters

Name Type Default value Description
$contentType ContentType - -
$creator User null

If null the current-user is used instead

Return values

ContentType

Tags
Throws
UnauthorizedException

if the current-user is not allowed to copy a content type

publiccreateContentType()

ContentTypeService.php : 112

Create a content type object.

public createContentType(ContentTypeCreateStruct $contentTypeCreateStruct, array<string|int, ContentTypeGroup$contentTypeGroups) : ContentTypeDraft

The content type is created in the state STATUS_DRAFT.

Parameters

Name Type Default value Description
$contentTypeCreateStruct ContentTypeCreateStruct - -
$contentTypeGroups array<string|int, ContentTypeGroup> -

Required array of ContentTypeGroup to link type with (must contain one)

Return values

ContentTypeDraft

Tags
Throws
UnauthorizedException

if the user is not allowed to create a content type

Throws
InvalidArgumentException

In case when

  • array of content type groups does not contain at least one content type group
  • identifier or remoteId in the content type create struct already exists
  • there is a duplicate field identifier in the content type create struct
Throws
ContentTypeFieldDefinitionValidationException

if a field definition in the $contentTypeCreateStruct is not valid

publiccreateContentTypeDraft()

ContentTypeService.php : 199

Creates a draft from an existing content type.

public createContentTypeDraft(ContentType $contentType) : ContentTypeDraft

This is a complete copy of the content type which has the state STATUS_DRAFT.

Parameters

Name Type Default value Description
$contentType ContentType - -

Return values

ContentTypeDraft

Tags
Throws
UnauthorizedException

if the user is not allowed to edit a content type

Throws
BadStateException

If there is already a draft assigned to another user

publiccreateContentTypeGroup()

ContentTypeService.php : 35

Create a content type group object.

public createContentTypeGroup(ContentTypeGroupCreateStruct $contentTypeGroupCreateStruct) : ContentTypeGroup

Parameters

Name Type Default value Description
$contentTypeGroupCreateStruct ContentTypeGroupCreateStruct - -

Return values

ContentTypeGroup

Tags
Throws
UnauthorizedException

if the user is not allowed to create a content type group

Throws
InvalidArgumentException

If a group with the same identifier already exists

publicdeleteContentType()

ContentTypeService.php : 226

Delete a content type object.

public deleteContentType(ContentType $contentType) : void

Deletes a content type if it has no instances. If content type in state STATUS_DRAFT is given, only the draft content type will be deleted. Otherwise, if content type in state STATUS_DEFINED is given, all content type data will be deleted.

Parameters

Name Type Default value Description
$contentType ContentType - -
Tags
Throws
BadStateException

If there exist content objects of this type

Throws
UnauthorizedException

if the user is not allowed to delete a content type

publicdeleteContentTypeGroup()

ContentTypeService.php : 91

Delete a content type group.

public deleteContentTypeGroup(ContentTypeGroup $contentTypeGroup) : void

This method only deletes an content type group which has content types without any content instances

Parameters

Name Type Default value Description
$contentTypeGroup ContentTypeGroup - -
Tags
Throws
UnauthorizedException

if the user is not allowed to delete a content type group

Throws
InvalidArgumentException

If a to be deleted content type has instances

publicdeleteUserDrafts()

ContentTypeService.php : 395

Delete all content type drafs created or modified by the user.

public deleteUserDrafts(int $userId) : void

Parameters

Name Type Default value Description
$userId int - -

publicisContentTypeUsed()

ContentTypeService.php : 380

Returns true if the given content type $contentType has content instances.

public isContentTypeUsed(ContentType $contentType) : bool

Parameters

Name Type Default value Description
$contentType ContentType - -

Return values

bool

publicloadContentType()

ContentTypeService.php : 124

Get a content type object by id.

public loadContentType(int $contentTypeId[, array<string|int, string> $prioritizedLanguages = [] ]) : ContentType

Parameters

Name Type Default value Description
$contentTypeId int - -
$prioritizedLanguages array<string|int, string> []

Used as prioritized language code on translated properties of returned object.

Return values

ContentType

Tags
Throws
NotFoundException

If a content type with the given id and status DEFINED can not be found

publicloadContentTypeByIdentifier()

ContentTypeService.php : 136

Get a content type object by identifier.

public loadContentTypeByIdentifier(string $identifier[, array<string|int, string> $prioritizedLanguages = [] ]) : ContentType

Parameters

Name Type Default value Description
$identifier string - -
$prioritizedLanguages array<string|int, string> []

Used as prioritized language code on translated properties of returned object.

Return values

ContentType

Tags
Throws
NotFoundException

If content type with the given identifier and status DEFINED can not be found

publicloadContentTypeByRemoteId()

ContentTypeService.php : 148

Get a content type object by id.

public loadContentTypeByRemoteId(string $remoteId[, array<string|int, string> $prioritizedLanguages = [] ]) : ContentType

Parameters

Name Type Default value Description
$remoteId string - -
$prioritizedLanguages array<string|int, string> []

Used as prioritized language code on translated properties of returned object.

Return values

ContentType

Tags
Throws
NotFoundException

If content type with the given remote id and status DEFINED can not be found

publicloadContentTypeDraft()

ContentTypeService.php : 160

Get a content type object draft by id.

public loadContentTypeDraft(int $contentTypeId[, bool $ignoreOwnership = false ]) : ContentTypeDraft

Parameters

Name Type Default value Description
$contentTypeId int - -
$ignoreOwnership bool false

if true, method will return draft even if the owner is different than currently logged in user

Return values

ContentTypeDraft

Tags
Throws
NotFoundException

If the content type draft owned by the current user can not be found

publicloadContentTypeGroup()

ContentTypeService.php : 47

Get a content type group object by id.

public loadContentTypeGroup(int $contentTypeGroupId[, array<string|int, string> $prioritizedLanguages = [] ]) : ContentTypeGroup

Parameters

Name Type Default value Description
$contentTypeGroupId int - -
$prioritizedLanguages array<string|int, string> []

Used as prioritized language code on translated properties of returned object.

Return values

ContentTypeGroup

Tags
Throws
NotFoundException

If group can not be found

publicloadContentTypeGroupByIdentifier()

ContentTypeService.php : 59

Get a content type group object by identifier.

public loadContentTypeGroupByIdentifier(string $contentTypeGroupIdentifier[, array<string|int, string> $prioritizedLanguages = [] ]) : ContentTypeGroup

Parameters

Name Type Default value Description
$contentTypeGroupIdentifier string - -
$prioritizedLanguages array<string|int, string> []

Used as prioritized language code on translated properties of returned object.

Return values

ContentTypeGroup

Tags
Throws
NotFoundException

If group can not be found

publicloadContentTypeGroups()

ContentTypeService.php : 68

Get all content type groups.

public loadContentTypeGroups([array<string|int, string> $prioritizedLanguages = [] ]) : array<string|int, ContentTypeGroup>

Parameters

Name Type Default value Description
$prioritizedLanguages array<string|int, string> []

Used as prioritized language code on translated properties of returned object.

Return values

array<string|int, ContentTypeGroup>

publicloadContentTypeList()

ContentTypeService.php : 174

Bulk-load content type objects by ids.

public loadContentTypeList(array<string|int, int> $contentTypeIds[, array<string|int, string> $prioritizedLanguages = [] ]) : array<string|int, ContentType>|iterable<string|int, mixed>

Note: it does not throw exceptions on load, just ignores erroneous items.

Parameters

Name Type Default value Description
$contentTypeIds array<string|int, int> - -
$prioritizedLanguages array<string|int, string> []

Used as prioritized language code on translated properties of returned object.

Return values

array<string|int, ContentType>|iterable<string|int, mixed>

publicloadContentTypes()

ContentTypeService.php : 184

Get content type objects which belong to the given content type group.

public loadContentTypes(ContentTypeGroup $contentTypeGroup[, array<string|int, string> $prioritizedLanguages = [] ]) : array<string|int, ContentType>

Parameters

Name Type Default value Description
$contentTypeGroup ContentTypeGroup - -
$prioritizedLanguages array<string|int, string> []

Used as prioritized language code on translated properties of returned object.

Return values

array<string|int, ContentType>

an array of ContentType which have status DEFINED

publicnewContentTypeCreateStruct()

ContentTypeService.php : 338

Instantiates a new content type create class.

public newContentTypeCreateStruct(string $identifier) : ContentTypeCreateStruct

Parameters

Name Type Default value Description
$identifier string - -

Return values

ContentTypeCreateStruct

publicnewContentTypeGroupCreateStruct()

ContentTypeService.php : 329

Instantiates a new content type group create class.

public newContentTypeGroupCreateStruct(string $identifier) : ContentTypeGroupCreateStruct

Parameters

Name Type Default value Description
$identifier string - -

Return values

ContentTypeGroupCreateStruct

publicnewContentTypeGroupUpdateStruct()

ContentTypeService.php : 352

Instantiates a new content type update struct.

public newContentTypeGroupUpdateStruct() : ContentTypeGroupUpdateStruct

Return values

ContentTypeGroupUpdateStruct

publicnewContentTypeUpdateStruct()

ContentTypeService.php : 345

Instantiates a new content type update struct.

public newContentTypeUpdateStruct() : ContentTypeUpdateStruct

Return values

ContentTypeUpdateStruct

publicnewFieldDefinitionCreateStruct()

ContentTypeService.php : 362

Instantiates a field definition create struct.

public newFieldDefinitionCreateStruct(string $identifier, string $fieldTypeIdentifier) : FieldDefinitionCreateStruct

Parameters

Name Type Default value Description
$identifier string -

the required identifier for the field definition

$fieldTypeIdentifier string -

the required field type identifier

Return values

FieldDefinitionCreateStruct

publicnewFieldDefinitionUpdateStruct()

ContentTypeService.php : 369

Instantiates a field definition update class.

public newFieldDefinitionUpdateStruct() : FieldDefinitionUpdateStruct

Return values

FieldDefinitionUpdateStruct

publicpublishContentTypeDraft()

ContentTypeService.php : 320

Publish the content type and update content objects.

public publishContentTypeDraft(ContentTypeDraft $contentTypeDraft) : void

This method updates content objects, depending on the changed field definitions.

Parameters

Name Type Default value Description
$contentTypeDraft ContentTypeDraft - -
Tags
Throws
BadStateException

If the content type has no draft

Throws
InvalidArgumentException

If the content type has no field definitions

Throws
UnauthorizedException

if the user is not allowed to publish a content type

publicremoveContentTypeTranslation()

ContentTypeService.php : 388
public removeContentTypeTranslation(ContentTypeDraft $contentTypeDraft, string $languageCode) : ContentTypeDraft

Parameters

Name Type Default value Description
$contentTypeDraft ContentTypeDraft - -
$languageCode string - -

Return values

ContentTypeDraft

publicremoveFieldDefinition()

ContentTypeService.php : 294

Remove a field definition from an existing Type.

public removeFieldDefinition(ContentTypeDraft $contentTypeDraft, FieldDefinition $fieldDefinition) : void

Parameters

Name Type Default value Description
$contentTypeDraft ContentTypeDraft - -
$fieldDefinition FieldDefinition - -
Tags
Throws
InvalidArgumentException

If the given field definition does not belong to the given type

Throws
UnauthorizedException

if the user is not allowed to edit a content type

publicunassignContentTypeGroup()

ContentTypeService.php : 264

Unassign a content type from a group.

public unassignContentTypeGroup(ContentType $contentType, ContentTypeGroup $contentTypeGroup) : void

Parameters

Name Type Default value Description
$contentType ContentType - -
$contentTypeGroup ContentTypeGroup - -
Tags
Throws
UnauthorizedException

if the user is not allowed to link a content type

Throws
InvalidArgumentException

If the content type is not assigned this the given group.

Throws
BadStateException

If $contentTypeGroup is the last group assigned to the content type

publicupdateContentTypeDraft()

ContentTypeService.php : 212

Update a content type object.

public updateContentTypeDraft(ContentTypeDraft $contentTypeDraft, ContentTypeUpdateStruct $contentTypeUpdateStruct) : void

Does not update fields (fieldDefinitions), use ContentTypeService::updateFieldDefinition() to update them.

Parameters

Name Type Default value Description
$contentTypeDraft ContentTypeDraft - -
$contentTypeUpdateStruct ContentTypeUpdateStruct - -
Tags
Throws
UnauthorizedException

if the user is not allowed to update a content type

Throws
InvalidArgumentException

If the given identifier or remoteId already exists.

publicupdateContentTypeGroup()

ContentTypeService.php : 79

Update a content type group object.

public updateContentTypeGroup(ContentTypeGroup $contentTypeGroup, ContentTypeGroupUpdateStruct $contentTypeGroupUpdateStruct) : void

Parameters

Name Type Default value Description
$contentTypeGroup ContentTypeGroup -

the content type group to be updated

$contentTypeGroupUpdateStruct ContentTypeGroupUpdateStruct - -
Tags
Throws
UnauthorizedException

if the user is not allowed to create a content type group

Throws
InvalidArgumentException

If the given identifier (if set) already exists

publicupdateFieldDefinition()

ContentTypeService.php : 307

Update a field definition.

public updateFieldDefinition(ContentTypeDraft $contentTypeDraft, FieldDefinition $fieldDefinition, FieldDefinitionUpdateStruct $fieldDefinitionUpdateStruct) : void

Parameters

Name Type Default value Description
$contentTypeDraft ContentTypeDraft -

the content type draft

$fieldDefinition FieldDefinition -

the field definition which should be updated

$fieldDefinitionUpdateStruct FieldDefinitionUpdateStruct - -
Tags
Throws
InvalidArgumentException

If the field id in the update struct is not found or does not belong to the content type of If the given identifier is used in an existing field of the given content type

Throws
UnauthorizedException

if the user is not allowed to edit a content type