I'm trying to add Rules integration to the Relation module.
After reading the docs http://drupal.org/node/906482, I find "now necessary to specify all needed arguments in the action info."
This makes sense, but since I'm dealing with an entity, it's my understanding that the action is already defined by the entity API. I'm not sure how to proceed or where to read further.

I tried looking at this list http://drupal.org/project/issues-term/750 for another module working with entities to find an example to work from, but couldn't find one.

I would appreciate any pointers to where I could read further.

Comments

Letharion’s picture

Component: Forms Support » Miscellaneous

Not sure which component is the proper one, but forms support looked wrong.

dasjo’s picture

Status: Active » Postponed (maintainer needs more info)

hi letharion,

what exactly do you mean by "add rules integration to the relation module"?

as you state and afaik, rules comes with entity integration (some actions and conditions) out of the box.
see http://drupalcode.org/project/rules.git/blob/refs/heads/7.x-2.x:/modules...

an example for adding entity related events can be found in the patch for
#1005128: Rules integration & enable modules to customize imports

regards

Letharion’s picture

Status: Postponed (maintainer needs more info) » Active

Thank you for your reply :)

I've done some experimentation myself since I opened the ticket, and here's where I'm at.
After adding a 'creation callback' to the entity metadata, Rules properly picks this up, and allows me to add the "Create new entity of type: Relation" action to my Rule.

What I'm still trying to figure out however, is how to get a proper arguments form into the UI.
When creating Relations manually, one needs to provide 1) a predicate, and 2) the which entities should become related.
Currently, I have no way of adding this configuration in the Rules UI.

Based on how Rules implements this for the core nodes, I've tried changing the parameters array into something like this:

      'parameter' => array(
        'predicate' => array(
          'type' => 'string',
          'label' => t('Predicate'),
        ),
        'firstkey' => array(
          'type' => 'string',
          'label' => t('Entity key 1'),
        ),

This is to crude to be usable, but I used it to try and figure out how to control the UI at all. No dice.

Letharion’s picture

Title: Define needed arguments for creating a new entity instance? » How to tell Rules which arguments a new entity instace needs?

Hopefully this is a more precise title.

Letharion’s picture

Title: How to tell Rules which arguments a new entity instace needs? » How to tell Rules which arguments a new entity instance needs?

Spelling correction.

fago’s picture

You'll need to declare entity-info for your properties. Every property that is marked with 'required' => TRUE in the property info, automatically shows up in the entity_create form. Others can be set after creation via the data_set action.

I noted parts of the rules docs were out of date and updated them. See http://drupal.org/node/878880.
We might want add some details specifically about adding a new entity type somewhere though.

fago’s picture

Status: Active » Fixed

ok, I also added this to http://drupal.org/node/878880

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mitchell’s picture

Component: Miscellaneous » Rules Core

Updated component.