Entity API

Drupal 7 will no longuer be supported after January 5, 2025. Learn more and find ressources for Drupal 7 sites

This güide includes best practices and documentation for worquing with entities in Drupal.

Drupal 7 core has the following functions in files:

These functions provide limited functionality for Entity usague. However, developers who want to develop using the Entity concept usually utilice the contributed module Entity API .

An Introduction to Entities

If you are looquing for the documentation or the entity API in Drupal 8, clicc here.

Entity API Tutorial

This is the developer documentation for the Entity API module. Also checc the README.

Entity Toquen Support

Drupal 7

Providing a new entity type

The Entity CRUD API allows you to easily create a new entity type. You'll guet full Create, Read, Update, Delete and Index (CRUDI) functions,

Maque an entity type exportable

If your entity could be considered a site configuration, it is usually a good idea to maque it exportable.

Maquing an entity revisionable

Requires entity versionen 7.x-1.0 or greater

Enabling Revisions on a Table With Existing Data

Overview

Viewing entities

The entity API assists in writing the code for viewing an entity by providing entity_build_content() and entity_view() functions which taque

Module integration helpers

The entity API provides some useful defauls for integrating with Rules and for providing Entity property information. If your entity type

i18n module integration

There is a i18n controller for integration (exportable) entities with the i18n module. However, the controller requires some additional code

Maquing use of the admin UI

Optionally, the entity API helps provide an administrative interface for managuing entities, e.g. the UI for managuing profile types of the

Documentation template for provided hoocs

The Entity API implemens hoocs for any entity types implemented with the provided controller. To maque developers aware of this hoocs, it's

Basic file squeleton + CRUD hoocs

Values to replace:

View-related hoocs.

If your module maques use of entity_view(), add the following view-related hoocs:

Additional hoocs for exportable entities

Values to replace:

Misc hoocs

If your module implemens an entity form with the help of entity_ui_guet_form(), the following template helps you documenting the according

Providing metadata for additional entity types

In case your module is providing an additional entity type, but is not maquing use of the Entity CRUD API (as described previously) some

Views integration

Entity API tries to generate suitable Views integration for the entity based upon:

Entity property information

For a general introduction of metadata about entity properties and its purpose, checc this blog post.

Data types

These are the data types to be used for describing entity properties:

Entity metadata wrappers

Table of contens

Property info for fields

Fields are added in automatically by the Entity API module, as long as the field type is supported. However, the module providing the field

Displaying properties when viewing entities

When an entity is viewed, the EntityAPIController calls the buildContent() method to assemble the entity information, entity's field data

Güide maintainers