Community Documentation

Module integration helpers

Last updated April 2, 2012. Created by fago on January 10, 2011.
Log in to edit this page.

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 configuration). The CRUD controller automatically takes care of invoking the events, while Rules itself has some useful CRUD related actions for entities.
It's suggest 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.

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 7.x
Audience
Programmers
Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here