I am having a hard time understanding the term custom entity type.
If it at all matters, I understood entity type itself to be a kind of "template" for content types.

I became confused after reading the following:

Create a simple translatable (custom entity type or content type) called translation, having a title and a value field (and maybe a type which refers to a contextual "heading").

Is a custom entity type a content type, or can both at least be logically unified?

  • 4
  • You are starting now to change the meaning of your question and invalidating the already given answer by that. What do you want to know? Custom entity or custom entity type? – leymannx Jan 7 at 7:06
  • @leymannx I meant to ask only about custom entity type. If to understand this term I should first understand custom entity than I might need to ask another question. – JohnDoea Jan 7 at 8:21

Is custom entity type a content type


A "Node" is an entity type, and content types are entity bundles of Node (Article, Page). Also referred to as node types.

A custom entity type can be anything else you wish to create and may or may not have bundles depending on use-case; for example, User does not have bundles.

There are definitely cases where you may have data that is not Node based. You will know further cases when you hit that point.

Example from my 2018 project

The only offhand example I have is from a 2018 project where part of the site needed to display a decoupled app showing bookable rooms across the campus with information about each room. I created a custom "Room" entity type, exposed a REST route for it and such. A much older example would be a "Listing" entity type, this time with bundles: Residential, Commercial, Industrial, Lot, etc... because they all have different fields and usage, but all subtypes of the same parent type.

What you gain is a consistent way of dealing with the entity system and discoverability of the rest of Drupal, with the freedom to dictate how your entity functions or is used without being tied to Node or everything hooking into / acting on Nodes.

Side note

I think this is a confusing point in code/docs for Drupal because they all extend ContentEntityType but that does not imply that they are equivalent to what are called content types in the admin, nor does it mean a custom entity type is thought of as content in the way that nodes typically are. I suppose you don't have to extend ContentEntityType, but if you use Drupal Console to generate a new entity class, it will come that way.

  • 1
    What is they referring to in this is a confusing point in code/docs for Drupal because they all extend ContentEntityType? – kiamlaluno Jan 5 at 9:25
  • Sorry I meant that most entities extend from ContentEntityType, which can lead to confusion for people trying to understand what is an entity and why you would make your own or use Node. – Kevin Jan 5 at 15:28
  • No need to be sorry: It was me trying to understand if they was referring to entities and content types. – kiamlaluno Jan 6 at 9:23
  • Hello Kevin, I understand this: both a node and a content type are entity types while a content type is practically "bundle" of nodes and might also be referred to as a node type. Did I understood correct? – JohnDoea Jan 7 at 10:36
  • 1
    A content type is not an entity type, a content type (node type) is a bundle of Node. Bundles are config entities. This is a confusing point in the terminology and code. Entities (most) extend the ContentEntityType class. Check the NodeType and Node class annotations for some clarification here. – Kevin Jan 7 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.