Module integration helpers

Last updated on
26 April 2017

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

The entity API provides some useful defaults for integrating with rules and for providing Entity property information. If your entity type is exportable, also some Features integration is provided.

All of those integrations are powered by a separate controller class, which may be specified in hook_entity_info(). Thus for doing customizations, just override the default class and specify your class in the hook.

Rules

For Rules the basic events for the according CRUD hooks are provided (as long as your entity is not configured). The CRUD controller automatically takes care of invoking the events, while Rules itself has some useful CRUD related actions for entities.
It's suggested to specify an access callback in hook_entity_info(), as this is picked up by the Rules integration. To further improve the defaults, best improve the Entity property info integration and provide additional events, conditions and actions as appropriate.

Entity property info

Some basic metadata about your entity's properties is generated out of the db schema you specified in hook_schema(). While this is usually a good start, it's not complete and the system cannot distinguish whether your integer is a timestamp, duration or whatever in reality.
So to improve the defaults, you have to care about specifying proper access levels, labels and description and provide additional properties where it makes sense, e.g. For referenced entities ala node:author. Also the defaults do not incorporate any write support, to get that you have to add in the appropriate setter callbacks yourself.

Views

The views integration controller provides Views integration for entities stored in Drupal's database. Make sure to complete your Entity property info (see above) to obtain support for views relationships (including reverse relationships) as well as proper support for date properties.

Features

Exportable entities are automatically integrated with the Features module, such that they can be exported and bundled in a feature. Usually the defaults should work well, whereas they may be overridden as usual.

I18n

There is a i18n controller for integration (exportable) entities with the i18n module. See the separate page for details.

Help improve this page

Page status: No known problems

You can: