4. Adding further entity types

Last modified: December 13, 2007 - 16:01

Workflow-ng is working based on arguments, which have a defined entity type like 'node' or 'user'. Events specify the type of the entities they provide and conditions and actions specify, with which entity types they are compatible.
So each condition and action may be configured for every event, which provides arguments of the required entity type.

So if a module generates new events and/or provides new conditions and actions, it can also specify new entity types.
However, if one writes an action which needs an entity of type 'custom1', one needs such an entity to execute this action. These entities may be provided by contributed events.
In short: One can specify an event, which provides an argument of type 'custom1', and an action which needs the argument of type 'custom1' - so the action can be configured to be executed on this event.

Workflow-ng can also handle the saving of arguments intelligently, which means, if several actions modify the entity, it will be saved only one time. However to make use of this feature, workflow-ng needs to know how to save the entity. For this you need to specify a handler, which handles the saving of the entity.
Also have a look at the action writing docs, to see how the action has to support this.

Specifying a saving handler

The saving handler of an entity is specified with the help of hook_entity_info(). You will need only to implement this hook for your entity type, if you want to specify a saving handler.

<?php
/*
* Implementation of hook_entity_info
*/
function workflow_ng_entity_info() {
  return array(
   
'node' => array('#save' => 'node_save'),
   
'comment' => array('#save' => 'workflow_ng_comment_save')
  );
}

/*
* Wrappers around drupal's saving functions
*/
function workflow_ng_comment_save($comment) {
 
comment_save((array)$comment);
}
?>

This is workflow-ng's hook_entity_info - as you see, currently it provides saving handler for nodes and comments.

 
 

Drupal is a registered trademark of Dries Buytaert.