function relation_rules_fetch_endpoint_info_alter in Relation 8
Same name and namespace in other branches
- 8.2 relation.rules.inc \relation_rules_fetch_endpoint_info_alter()
- 7 relation.rules.inc \relation_rules_fetch_endpoint_info_alter()
Info alter callback for the fetch_endpoint action.
File
- ./
relation.rules.inc, line 323 - Implements the Rules module API for Relation.
Code
function relation_rules_fetch_endpoint_info_alter(&$element_info, $element) {
$element->settings += array(
'relation:select' => NULL,
);
if ($wrapper = $element
->applyDataSelector($element->settings['relation:select'])) {
// We only make this parameter available after we've selected the relation. This way we
// can limit the entity type list to only those relative to the selected relation.
$element_info['parameter']['entity_type'] = array(
'type' => 'text',
'label' => t('Entity type'),
'options list' => 'relation_rules_fetch_endpoint_type_options',
'description' => t('Select the specific entity type to return.'),
);
if (!empty($element->settings['entity_type'])) {
// Having a number parameter allows us to be flexible between returning a list or a single entity.
$element_info['parameter']['number'] = array(
'type' => 'integer',
'label' => t('How many endpoints to return'),
'default value' => 1,
'description' => t('The number of enitites to return that match the above entity type criteria and in what form (single entity or a list). !zero returns a list containing every entity found; The default !one will return a single entity; !gt1 returns a list with maximum the specified number of entities.', array(
'!zero' => '<strong>0</strong>',
'!one' => '<strong>1</strong>',
'!gt1' => '<strong># > 1</strong>',
)),
);
// Set the returned entity type so we can access all the data.
if (!empty($element->settings['number']) && 1 == $element->settings['number']) {
$element_info['provides']['endpoint_fetched']['type'] = $element->settings['entity_type'];
// Only one.
}
else {
$element_info['provides']['endpoint_fetched']['type'] = 'list<' . $element->settings['entity_type'] . '>';
// More then one.
}
}
}
}