Entity 在 drupal 里是一个很重要的概念。个人理解:drupal 也是在面向对象的思想上对其提炼,即世上万物皆对象。其概念有点类似生物学上的界门纲目科属种层级关系。Entity type 就是大类,比如水果;Bundle 就是子类,比如西瓜;Field 就是水果属性,比如西瓜是圆的,绿皮带条纹,有籽无籽等。而 Entity 就是更具象指这个西瓜(实例)。
- An entity type is a base class
- A bundle is an extended class
- A field is a class member, property, variable or field instance (depending on your naming preference)
- An entity is an object or instance of a base or extended class
In Drupal 8, bundles are a type of container for information that holds the field or setting definitions. They are sometimes called "sub-types". Bundles are optional and in the hierarchy of container types for information they fit below entity types.
- Entity variants (content and configuration; many entities come in pairs, e.g. blocks)
- Entity types
- Bundles, or sub-types (optional)
- Entity types
Examples of those container types are as follows:
- Entity Variants:
- Content
- Content Entity Types:
- Node
- Node Bundles, aka Content Types:
- Article
- Basic page
- Node Bundles, aka Content Types:
- Taxonomy
- Taxonomy Bundles, aka Vocabularies:
- <Vocabulary A>
- <Vocabulary B>
- <Vocabulary Etc.>
- Taxonomy Bundles, aka Vocabularies:
- Blocks
- Custom Block Bundles, aka Custom Block Types:
- <Block Type L>
- <Block Type M>
- <Block Type Etc.>
- Custom Block Bundles, aka Custom Block Types:
- User (has no child bundles)
- <Custom content entity type X>
- <Custom content entity type Y>
- <Custom content entity type Etc.>
- Node
- Content Entity Types:
- Configuration
- Configuration Entity Types:
- Custom Block types(has no child bundles?)
- View(has no child bundles)
- Menu (has no child bundles)
- Role (has no child bundles)
- <Custom config entity type I>
- <Custom config entity type II>
- <Custom config entity type Etc.>
- Configuration Entity Types:
- Content