This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » eZ Publish 5 Platform » How to retrieve the contentType...

How to retrieve the contentType Identifier aka "class_identifier"

How to retrieve the contentType Identifier aka "class_identifier"

Tuesday 09 April 2013 8:05:07 am - 2 replies

When I did used the following code :


as specified  in the,finding,viewing-ContentInfoproperties

I got the following error :

Property 'contentType' not found on class 'eZ\Publish\API\Repository\Values\Content\ContentInfo'


I had to code the following lines to retrieve the identifier, as it is a property of ContentType :

$contentTypeService = $repository->getContentTypeService();               

$contentType = $contentTypeService->loadContentType($contentInfo->contentTypeId);

$identifier = $contentType->identifier; 


Do you plan to add a method or a property to get the ContentType like in the sample ?

To have to use the ContentTypeService is quite cumbersome, but maybe we have to use contentTypeId instead of identifier ?


Best regards


Tuesday 09 April 2013 9:52:32 am

contentType and relations where part of Content in 5.0, but deprecated as they made loading content very heavy so it's been removed after 5.0. We did consider keeping content type identifier for misc use cases, what is your use case? As in; what do you use the identifier for?

Tuesday 09 April 2013 1:38:12 pm

In eZPublish 4.X I did used the class_identifier typically in an Event Type, an Edit Handler, and some times in batch process.

So I can go without having a method or propert in contentInfo, but it would be nice to remove the reference to this deprecated property in the cookbook. 

I wonder for example if relying on them in a PreContentViewListener would be a good practice.

The contentTypeId is less user friendly, and depends of the environment.

I agree with you, that loading contentType each time is too heavy, so using the contentService is no problem.

When I call loadContentType, is there some cache, or had I to cache the identifier my self to avoid having to access the db each time ?


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from