Community Documentation

Entity type metadata

Last updated November 1, 2012. Created by fago on August 10, 2010.
Edited by gollyg, mitchell, August1914. Log in to edit this page.

Rules makes use of metadata for dealing with entities and their properties. A good strategy to integrate with Rules is by providing metadata with the Entity API. To add new entity types and entity metadata see its supported properties).

rules architecture

  • If you provide a new entity type to the system, use its additional hook_entity_info() keys to tell it how your entity is saved / deleted / created and to specify an access callback - Rules will pick that up. Additionally implement hook_entity_property_info() for providing metadata about the existing entity properties. In particular, be sure to mark properties required to create an entity with 'required' => TRUE as this is required for the 'entity_create' action to function.
  • Implement hook_entity_property_info_alter() in order to add metadata about any properties your module adds to existing entity types.

All properties known to the Entity API are accessible in Rules for use as arguments via the data selectors. If a 'setter callback' is provided, the data property can be modified via the "Set data value" action. Also, Rules makes use of any given 'options list' callback or any specified access info.

For more details check the Entity API docs.

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.