Versions
Release Date
Version | Release Date |
---|---|
8.2.4 | December 07, 2016 |
7.53 | December 07, 2016 |
6.38 (unsupported) | February 24, 2016 |
5.23 (unsupported) | August 11, 2010 |
Entity types
In earlier versions of Drupal, the field system was only used on content types. Now, thanks to the Entity API, we can add fields to other things, like comments. Fieldable entities make Drupal eminently flexible. An entity type is a useful abstraction to group together fields. Below are the Entity types in Drupal core:
You can also build new kinds of entity types where the options above don't suit your needs.
Bundles
Bundles are an implementation of an entity type to which fields can be attached. You can consider bundles as subtypes of an entity type. With content nodes (an entity type), for example, you can generate bundles (subtypes) like articles, blog posts, or products. Not all entity types have bundles, however. For example, users do not have separate bundles (subtypes). For the entity types that do allow bundles, you can create as many bundles (subtypes) as you want. Then, using the Field system, you can add different fields to each bundle. Examples include a file download field on Basic Pages and a subtitle field on Articles.
Fields
A field is a reusable piece of content. In technical terms, each field is a primitive data type, with custom validators and widgets for editing and formatters for display. You can read further for a developer's guide to using the Drupal 7 Fields API.
What's important to know as it relates to Entities is that Fields can be added to any of the bundles (or entity types) to help organize their data.
Say, for example, you create a content type with an unstructured text field and use HTML to structure parts of it, like a summary section, or prices. That would make it more difficult, then, to control how these were displayed, or to make connections between different types of related content.
This is where using fields is essential. You could create a summary field of type Long Text as well as price fields of type Decimal.
Entity
An entity would be one instance of a particular entity type such as a comment, taxonomy term or user profile or of a bundle such as a blog post, article or product.
You can use entity_load to load any entity. Note, however, that the core does not provide a save or delete function, but thanks to Entity API module the missing pieces are added (entity_create(), entity_save(), entity_delete(), entity_view() and entity_access()).
Putting this in Object-Oriented Design/Programming terms...
If you come from an OOD/P background and are trying to better understand what these key concepts are, the following suggested mapping might help (albeit not strictly true from a purist’s perspective) :-
All these four OOD/P concepts are special in that they are serialisable (stored - e.g. to a database or file). Serialisation takes place via the Entity API.