drupal entity type 和 bundle 概念理解

Ng
2019.04.28
Comment

Entity 在 drupal 里是一个很重要的概念。个人理解:drupal 也是在面向对象的思想上对其提炼,即世上万物皆对象。其概念有点类似生物学上的界门纲目科属种层级关系。Entity type 就是大类,比如水果;Bundle 就是子类,比如西瓜;Field 就是水果属性,比如西瓜是圆的,绿皮带条纹,有籽无籽等。而 Entity 就是更具象指这个西瓜(实例)。

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

via

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)

Examples of those container types are as follows:

  • Entity Variants:
    1. Content
      • Content Entity Types:
        1. Node
          • Node Bundles, aka Content Types:
            1. Article
            2. Basic page
        2. Taxonomy
          • Taxonomy Bundles, aka Vocabularies:
            1. <Vocabulary A>
            2. <Vocabulary B>
            3. <Vocabulary Etc.>
        3. Blocks
          • Custom Block Bundles, aka Custom Block Types:
            1. <Block Type L>
            2. <Block Type M>
            3. <Block Type Etc.>
        4. User (has no child bundles)
        5. <Custom content entity type X>
        6. <Custom content entity type Y>
        7. <Custom content entity type Etc.>
    2. Configuration
      • Configuration Entity Types:
        1. Custom Block types(has no child bundles?)
        2. View(has no child bundles)
        3. Menu (has no child bundles)
        4. Role (has no child bundles)
        5. <Custom config entity type I>
        6. <Custom config entity type II>
        7. <Custom config entity type Etc.>

via

Entity type
Bundle

Add new comment