You are here

function relation_rules_load_related_info_alter in Relation 8

Same name and namespace in other branches
  1. 8.2 relation.rules.inc \relation_rules_load_related_info_alter()
  2. 7 relation.rules.inc \relation_rules_load_related_info_alter()

Info alter callback for the load_related action.

File

./relation.rules.inc, line 202
Implements the Rules module API for Relation.

Code

function relation_rules_load_related_info_alter(&$element_info, $element) {
  if (!empty($element->settings['relation_type'])) {

    // We only make this parameter available after we've selected the relation type. This way we
    // can limit the entity type list to only those relative to the selected relation.
    $element_info['parameter']['entity_type_op'] = array(
      'type' => 'text',
      'label' => t('Entity type'),
      'options list' => 'relation_rules_fetch_endpoint_type_options',
      'optional' => TRUE,
      'default value' => '',
      'description' => t('Optional: Select the specific type of entities to return. This will allow you to access their field/property data.'),
    );
    if (!empty($element->settings['entity_type_op'])) {

      // Set the returned entity type so we can access all the data.
      $element_info['provides']['endpoints']['type'] = 'list<' . $element->settings['entity_type_op'] . '>';

      // More then one.
    }
  }
}