Class

eZ\Publish\Core\Persistence\Cache\ContentTypeHandler

class ContentTypeHandler extends AbstractHandler implements Handler

ContentType cache.

Caches defined (published) content types and content type groups.

Methods

Group createGroup(CreateStruct $struct)

updateGroup(UpdateStruct $struct)

deleteGroup(mixed $groupId)

Group loadGroup(mixed $groupId)

Group[] loadGroups(array $groupIds)

Return list of unique Content Type Groups, with group id as key.

Group loadGroupByIdentifier(string $identifier)

Loads Type Group by identifier.

Group[] loadAllGroups()

Type[] loadContentTypes(mixed $groupId, int $status = Type::STATUS_DEFINED)

Type load($typeId, int $status = Type::STATUS_DEFINED)

Loads a content type by id and status.

Type loadByIdentifier(string $identifier)

Loads a (defined) content type by identifier.

Type loadByRemoteId(mixed $remoteId)

Loads a (defined) content type by remote id.

Type create(CreateStruct $struct)

update($typeId, int $status, UpdateStruct $struct)

delete($typeId, int $status)

Type createDraft(mixed $modifierId, $typeId)

Creates a draft of existing defined content type.

Type copy(mixed $userId, $typeId, int $status)

Copy a Type incl fields and group-relations from a given status to a new Type with status {@link Type::STATUS_DRAFT}.

unlink(mixed $groupId, $typeId, int $status)

Unlink a content type group from a content type.

link(mixed $groupId, $typeId, int $status)

Link a content type group with a content type.

FieldDefinition getFieldDefinition(mixed $id, int $status)

Returns field definition for the given field definition id.

int getContentCount(mixed $contentTypeId)

Counts the number of Content instances of the ContentType identified by given $contentTypeId.

FieldDefinition addFieldDefinition($typeId, int $status, FieldDefinition $struct)

Adds a new field definition to an existing Type.

removeFieldDefinition($typeId, int $status, mixed $fieldDefinitionId)

Removes a field definition from an existing Type.

updateFieldDefinition($typeId, int $status, FieldDefinition $struct)

This method updates the given $fieldDefinition on a Type.

publish($typeId)

Update content objects.

array getSearchableFieldMap()

Returns content type, field definition and field type mapping information for search engine usage.

Details

at line 31
public Group createGroup(CreateStruct $struct)

Parameters

CreateStruct $struct

Return Value

Group

at line 41
public updateGroup(UpdateStruct $struct)

Parameters

UpdateStruct $struct

at line 54
public deleteGroup(mixed $groupId)

Parameters

mixed $groupId

Exceptions

BadStateException If type group contains types
NotFoundException If type group with id is not found

at line 67
public Group loadGroup(mixed $groupId)

Parameters

mixed $groupId

Return Value

Group

Exceptions

NotFoundException If type group with id is not found

at line 87
public Group[] loadGroups(array $groupIds)

Return list of unique Content Type Groups, with group id as key.

Missing items (NotFound) will be missing from the array and not cause an exception, it's up to calling logic to determine if this should cause exception or not.

Parameters

array $groupIds

Return Value

Group[]

at line 106
public Group loadGroupByIdentifier(string $identifier)

Loads Type Group by identifier.

Legacy note: Uses name for identifier.

Parameters

string $identifier

Return Value

Group

Exceptions

NotFoundException If type group with id is not found

at line 126
public Group[] loadAllGroups()

Return Value

Group[]

at line 136
public Type[] loadContentTypes(mixed $groupId, int $status = Type::STATUS_DEFINED)

Parameters

mixed $groupId
int $status One of Type::STATUSDEFINED|Type::STATUSDRAFT|Type::STATUS_MODIFIED

Return Value

Type[]

at line 167
public Type load($typeId, int $status = Type::STATUS_DEFINED)

Loads a content type by id and status.

Note: This method is responsible of having the Field Definitions of the loaded ContentType sorted by placement.

Parameters

$typeId
int $status One of Type::STATUSDEFINED|Type::STATUSDRAFT|Type::STATUS_MODIFIED

Return Value

Type

Exceptions

NotFoundException If type with provided status is not found

at line 187
public Type loadByIdentifier(string $identifier)

Loads a (defined) content type by identifier.

Note: This method is responsible of having the Field Definitions of the loaded ContentType sorted by placement.

Parameters

string $identifier

Return Value

Type

Exceptions

NotFoundException If defined type is not found

at line 207
public Type loadByRemoteId(mixed $remoteId)

Loads a (defined) content type by remote id.

Note: This method is responsible of having the Field Definitions of the loaded ContentType sorted by placement.

Parameters

mixed $remoteId

Return Value

Type

Exceptions

NotFoundException If defined type is not found

at line 227
public Type create(CreateStruct $struct)

Parameters

CreateStruct $struct

Return Value

Type

at line 244
public update($typeId, int $status, UpdateStruct $struct)

Parameters

$typeId
int $status One of Type::STATUSDEFINED|Type::STATUSDRAFT|Type::STATUS_MODIFIED
UpdateStruct $struct

at line 261
public delete($typeId, int $status)

Parameters

$typeId
int $status One of Type::STATUSDEFINED|Type::STATUSDRAFT|Type::STATUS_MODIFIED

Exceptions

BadStateException If type is defined and still has content

at line 278
public Type createDraft(mixed $modifierId, $typeId)

Creates a draft of existing defined content type.

Updates modified date, sets $modifierId and status to Type::STATUS_DRAFT on the new returned draft.

Parameters

mixed $modifierId
$typeId

Return Value

Type

Exceptions

NotFoundException If type with defined status is not found

at line 291
public Type copy(mixed $userId, $typeId, int $status)

Copy a Type incl fields and group-relations from a given status to a new Type with status {@link Type::STATUS_DRAFT}.

New Content Type will have $userId as creator / modifier, created / modified should be updated, new remoteId created and identifier should be 'copyof_' or another unique string.

Parameters

mixed $userId
$typeId
int $status One of Type::STATUSDEFINED|Type::STATUSDRAFT|Type::STATUS_MODIFIED

Return Value

Type

Exceptions

NotFoundException If user or type with provided status is not found

Unlink a content type group from a content type.

Parameters

mixed $groupId
$typeId
int $status One of Type::STATUSDEFINED|Type::STATUSDRAFT|Type::STATUS_MODIFIED

Exceptions

NotFoundException If group or type with provided status is not found
BadStateException If $groupId is last group on $contentTypeId or not a group assigned to type

Link a content type group with a content type.

Parameters

mixed $groupId
$typeId
int $status One of Type::STATUSDEFINED|Type::STATUSDRAFT|Type::STATUS_MODIFIED

Exceptions

NotFoundException If group or type with provided status is not found
BadStateException If type is already part of group

at line 337
public FieldDefinition getFieldDefinition(mixed $id, int $status)

Returns field definition for the given field definition id.

Parameters

mixed $id
int $status One of Type::STATUSDEFINED|Type::STATUSDRAFT|Type::STATUS_MODIFIED

Return Value

FieldDefinition

Exceptions

NotFoundException If field definition is not found

at line 347
public int getContentCount(mixed $contentTypeId)

Counts the number of Content instances of the ContentType identified by given $contentTypeId.

Parameters

mixed $contentTypeId

Return Value

int

at line 357
public FieldDefinition addFieldDefinition($typeId, int $status, FieldDefinition $struct)

Adds a new field definition to an existing Type.

This method creates a new version of the Type with the $fieldDefinition added. It does not update existing content objects depending on the field (default) values.

Parameters

$typeId
int $status One of Type::STATUSDEFINED|Type::STATUSDRAFT|Type::STATUS_MODIFIED
FieldDefinition $struct

Return Value

FieldDefinition

Exceptions

NotFoundException If type is not found

at line 378
public removeFieldDefinition($typeId, int $status, mixed $fieldDefinitionId)

Removes a field definition from an existing Type.

This method creates a new version of the Type with the field definition referred to by $fieldDefinitionId removed. It does not update existing content objects depending on the field (default) values.

Parameters

$typeId
int $status One of Type::STATUSDEFINED|Type::STATUSDRAFT|Type::STATUS_MODIFIED
mixed $fieldDefinitionId

Exceptions

NotFoundException If field is not found

at line 397
public updateFieldDefinition($typeId, int $status, FieldDefinition $struct)

This method updates the given $fieldDefinition on a Type.

This method creates a new version of the Type with the updated $fieldDefinition. It does not update existing content objects depending on the field (default) values.

Parameters

$typeId
int $status One of Type::STATUSDEFINED|Type::STATUSDRAFT|Type::STATUS_MODIFIED
FieldDefinition $struct

Exceptions

NotFoundException If field is not found

at line 416
public publish($typeId)

Update content objects.

Updates content objects, depending on the changed field definitions.

A content type has a state which tells if its content objects yet have been adapted.

Flags the content type as updated.

Parameters

$typeId

Exceptions

NotFoundException If type with $contentTypeId and Type::STATUS_DRAFT is not found

at line 439
public array getSearchableFieldMap()

Returns content type, field definition and field type mapping information for search engine usage.

Only searchable field definitions will be included in the returned data.

Returns an array in the form:

array( "" => array( "" => array( "fielddefinitionid" => "", "fieldtypeidentifier" => "", ), ... ), ... )

Return Value

array