0

I am using the Reply module for comment threads on a custom entity (we'll call it myentity). I'd like to create a rule that triggers when certain properties of myentity are met. However, the Reply module has very minimal entity_property_info, and so there's no way for rules to reference myentity in a condition.

The Reply module creates a Reply entity, that references an entity via entity_id column and an entity_type column. So, I created a property_info_alter hook as follows:

function mymodule_entity_property_info_alter(&$info) {
  $properties = &$info['reply']['properties'];

  $properties['entity_id'] = array(
    'label' => t("Entity id"), 
    'description' => t("The entity this reply is associated with."), 
    'type' => 'entity',
    'getter callback' => 'entity_property_verbatim_get',
    'required' => TRUE,
    'schema field' => 'entity_id',
  );
}

When I create a condition in rules of "Entity is of Type", I expect to find my new property as an option like reply:entity-id but it doesn't. It only appears in the condition "Data Comparison".

I feel like I'm missing something very simple, but really can't put my finger on it. How do I get this property to appear as a referenced entity that I can then evaluate in Rules?

1 Answer 1

0

This works as-is. I actually had a typo in my code that took me a long time to catch. I'm leaving this up if anyone else has the same situation. The final code looked like this (cleaner):

function mymodule_entity_property_info_alter(&$info) {
  $properties = &$info['reply']['properties'];

  $properties['myentity'] = array(
    'label' => t("My Entity"), 
    'description' => t("The entity this reply is associated with."), 
    'type' => 'myentity',
    'required' => TRUE,
    'schema field' => 'entity_id',
  );
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.