你在这里

实体类型

原文链接:https://www.drupal.org/docs/8/api/entity-api/entity-types

本文翻译自Last updated on 14 January 2017的版本

  • Drupal 7 - 实体是普通的stdClass类。
  • Drupal 8 - 实体在drupal 8 中是特别类型,每一个entity类型都定义了一个class用于创建指定entity的instance。

Requirements
Entity classes must be placed in the Entity sub-namespace of the module that provides the entity type, e.g. \<span class="token package" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline;">Drupal<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span></span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">[</span>module_name<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">]</span>\<span class="token package" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline;">Entity</span>. This means entity class PHP files may be found in a module's src<span class="token operator" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">/</span>Entity directory.

The docblock for the class must contain an EntityType annotation that defines the metadata for entities of that type. These include things like the entity type's label, controllers, tables, etc. For a documented list of all the available metadata properties, refer to the \<span class="token package" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline;">Drupal<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>Core<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>Entity<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>Annotation<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>EntityType</span> class.

Naming

Entity type names should be prefixed with the module name if the entity type and module name aren't the same. Prefixing the entity type's class itself is not required since it lives within the namespace of the defining module, provided it is meaningful enough on its own. For example, the entity type for taxonomy terms is named taxonomy_term and the class name is Drupal\<span class="token package" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline;">taxonomy<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>Entity<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>Term</span>.

Interfaces

Drupal 8 recommends you type hint functions and methods with interfaces instead of classes. For example, the generic entity storage hooks type hint with EntityInterface as in <span class="token function" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(6, 71, 113);">hook_entity_insert</span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">(</span>EntityInterface <span class="token variable" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(6, 120, 190);">$entity</span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">)</span> and the node specific storage hooks type hint with NodeInterface as in <span class="token function" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(6, 71, 113);">hook_node_insert</span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">(</span>NodeInterface <span class="token variable" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(6, 120, 190);">$node</span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">)</span>.

Entity fields / properties are often very short, storage-centric and not very self-descriptive. Additionally, content entities don't use defined properties for their fields (including base fields like the node title) at all.

Therefore, the recommended approach is to provide an Interface with documented method names. A few rules to follow when doing so:

  • Methods usually have a get/set/is or similar prefix: getSomething(), setSomething($value), isSomething()
  • Only add methods for things that other code is supposed to change. The last changed date of nodes ($node->changed) isn't supposed to be changed, so there is <span class="token variable" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(6, 120, 190);">$node</span><span class="token operator" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">-</span><span class="token operator" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">&gt;</span><span class="token function" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(6, 71, 113);">getChangedTime</span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">(</span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">)</span> but no <span class="token variable" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(6, 120, 190);">$node</span><span class="token operator" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">-</span><span class="token operator" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">&gt;</span><span class="token function" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(6, 71, 113);">setChangedTime</span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">(</span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">)</span>method.
  • Use self-descriptive method names, for example, the method to access <span class="token variable" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(6, 120, 190);">$node</span><span class="token operator" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">-</span><span class="token operator" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">&gt;</span><span class="token property" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(158, 92, 0);">status</span> is called <span class="token variable" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(6, 120, 190);">$node</span><span class="token operator" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">-</span><span class="token operator" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">&gt;</span><span class="token function" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(6, 71, 113);">isPublished</span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">(</span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">)</span>.

Discoverability

To find out which entity types a module provides, refer to the classes in the Entity sub-namespace of that module that have an @EntityType annotation, which also contains the name in the id annotation key.

When trying to find where a given entity type is defined, the first thing to look for is the prefix of the entity type. If a module doesn't follow that naming convention, then it can be found by searching for id <span class="token operator" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">=</span> <span class="token string" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(48, 130, 23);">&quot;$type&quot;</span>. If the class or interface is known instead of the entity type, then the namespace of that indicates where it is coming from.

Example

core<span class="token operator" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">/</span>modules<span class="token operator" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">/</span>node<span class="token operator" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">/</span>src<span class="token operator" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">/</span>Entity<span class="token operator" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">/</span>Node<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">.</span>php:

<span class="token keyword keyword-namespace" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(83, 115, 141);">namespace</span> <span class="token package" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline;">Drupal<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>node<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>Entity</span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">;</span>

<span class="token keyword keyword-use" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(83, 115, 141);">use</span> <span class="token package" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline;">Drupal<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>Core<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>Entity<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>ContentEntityBase</span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">;</span>
<span class="token keyword keyword-use" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(83, 115, 141);">use</span> <span class="token package" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline;">Drupal<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>Core<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>Entity<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>EntityChangedTrait</span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">;</span>
<span class="token keyword keyword-use" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(83, 115, 141);">use</span> <span class="token package" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline;">Drupal<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>Core<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>Entity<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>EntityStorageInterface</span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">;</span>
<span class="token keyword keyword-use" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(83, 115, 141);">use</span> <span class="token package" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline;">Drupal<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>Core<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>Entity<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>EntityTypeInterface</span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">;</span>
<span class="token keyword keyword-use" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(83, 115, 141);">use</span> <span class="token package" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline;">Drupal<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>Core<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>Field<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>BaseFieldDefinition</span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">;</span>
<span class="token keyword keyword-use" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(83, 115, 141);">use</span> <span class="token package" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline;">Drupal<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>Core<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>Session<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>AccountInterface</span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">;</span>
<span class="token keyword keyword-use" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(83, 115, 141);">use</span> <span class="token package" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline;">Drupal<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>node<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>NodeInterface</span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">;</span>
<span class="token keyword keyword-use" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(83, 115, 141);">use</span> <span class="token package" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline;">Drupal<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>user<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">\</span>UserInterface</span><span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">;</span>

<span class="token comment" spellcheck="true" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(112, 112, 112);">/**
* Defines the node entity class.
*
* @ContentEntityType(
*   id = &quot;node&quot;,
*   label = @Translation(&quot;Content&quot;),
*   bundle_label = @Translation(&quot;Content type&quot;),
*   handlers = {
*     &quot;storage&quot; = &quot;Drupal\node\NodeStorage&quot;,
*     &quot;storage_schema&quot; = &quot;Drupal\node\NodeStorageSchema&quot;,
*     &quot;view_builder&quot; = &quot;Drupal\node\NodeViewBuilder&quot;,
*     &quot;access&quot; = &quot;Drupal\node\NodeAccessControlHandler&quot;,
*     &quot;views_data&quot; = &quot;Drupal\node\NodeViewsData&quot;,
*     &quot;form&quot; = {
*       &quot;default&quot; = &quot;Drupal\node\NodeForm&quot;,
*       &quot;delete&quot; = &quot;Drupal\node\Form\NodeDeleteForm&quot;,
*       &quot;edit&quot; = &quot;Drupal\node\NodeForm&quot;
*     },
*     &quot;route_provider&quot; = {
*       &quot;html&quot; = &quot;Drupal\node\Entity\NodeRouteProvider&quot;,
*     },
*     &quot;list_builder&quot; = &quot;Drupal\node\NodeListBuilder&quot;,
*     &quot;translation&quot; = &quot;Drupal\node\NodeTranslationHandler&quot;
*   },
*   base_table = &quot;node&quot;,
*   data_table = &quot;node_field_data&quot;,
*   revision_table = &quot;node_revision&quot;,
*   revision_data_table = &quot;node_field_revision&quot;,
*   translatable = TRUE,
*   list_cache_contexts = { &quot;user.node_grants:view&quot; },
*   entity_keys = {
*     &quot;id&quot; = &quot;nid&quot;,
*     &quot;revision&quot; = &quot;vid&quot;,
*     &quot;bundle&quot; = &quot;type&quot;,
*     &quot;label&quot; = &quot;title&quot;,
*     &quot;langcode&quot; = &quot;langcode&quot;,
*     &quot;uuid&quot; = &quot;uuid&quot;,
*     &quot;status&quot; = &quot;status&quot;,
*     &quot;uid&quot; = &quot;uid&quot;,
*   },
*   bundle_entity_type = &quot;node_type&quot;,
*   field_ui_base_route = &quot;entity.node_type.edit_form&quot;,
*   common_reference_target = TRUE,
*   permission_granularity = &quot;bundle&quot;,
*   links = {
*     &quot;canonical&quot; = &quot;/node/{node}&quot;,
*     &quot;delete-form&quot; = &quot;/node/{node}/delete&quot;,
*     &quot;edit-form&quot; = &quot;/node/{node}/edit&quot;,
*     &quot;version-history&quot; = &quot;/node/{node}/revisions&quot;,
*     &quot;revision&quot; = &quot;/node/{node}/revisions/{node_revision}/view&quot;,
*   }
* )
*/</span>
<span class="token keyword keyword-class" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(83, 115, 141);">class</span> <span class="token class-name" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline;">Node</span> <span class="token keyword keyword-extends" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(83, 115, 141);">extends</span> <span class="token class-name" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline;">ContentEntityBase</span> <span class="token keyword keyword-implements" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(83, 115, 141);">implements</span> <span class="token class-name" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline;">NodeInterface</span> <span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">{</span>
  <span class="token comment" spellcheck="true" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(112, 112, 112);">// ...</span>
<span class="token punctuation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; font-size: 14.7693px; vertical-align: baseline; color: rgb(85, 85, 85);">}</span>

To get a complete picture of the entities in Drupal 8 we can review the following diagram. This represent the entity classes. To view open in a new tab:

classdrupal_entities.png