function civicrm_entity_rules_action_entity_create_info_alter in CiviCRM Entity 7
Same name and namespace in other branches
- 7.2 civicrm_entity.module \civicrm_entity_rules_action_entity_create_info_alter()
Info alteration callback for the entity create action. Here we add a tonne of fields to civicrm entity create
1 string reference to 'civicrm_entity_rules_action_entity_create_info_alter'
- civicrm_entity_rules_action_info_alter in ./
civicrm_entity.module - Implements hook_rules_action_info_alter I can't seem to get my info_alter function called by hook so am doing this hacky intercept to call my function (& then go back to the main function if not a CiviCRM entity
File
- ./
civicrm_entity.module, line 1010 - Implement CiviCRM entities as a Drupal Entity.
Code
function civicrm_entity_rules_action_entity_create_info_alter(&$element_info, RulesAbstractPlugin $element) {
if (empty($element->settings['type']) || substr($element->settings['type'], 0, 8) != 'civicrm_') {
module_load_include('inc', 'rules', 'modules/entity.eval');
return rules_action_entity_create_info_alter($element_info, $element);
}
if (!empty($element->settings['type']) && entity_get_info($element->settings['type'])) {
$wrapper = entity_metadata_wrapper($element->settings['type']);
// Add the data type's needed parameter for loading to the parameter info.
foreach ($wrapper as $name => $child) {
$info = $child
->info();
$info += array(
'type' => 'text',
);
// Prefix parameter names to avoid name clashes with existing parameters.
$element_info['parameter']['param_' . $name] = array_intersect_key($info, array_flip(array(
'type',
'label',
'description',
)));
$element_info['parameter']['param_' . $name]['options list'] = $child
->optionsList() ? 'rules_action_entity_parameter_options_list' : FALSE;
$element_info['parameter']['param_' . $name]['optional'] = empty($info['required']);
}
unset($element_info['parameter']['type']);
foreach (civicrm_entity_get_custom_fields('contribution') as $fieldname => $field) {
$element_info['parameter'][$fieldname] = array(
'type' => $field['type'],
'label' => $field['label'],
'optional' => TRUE,
'default mode' => 'selector',
);
}
$element_info['provides']['entity_created']['type'] = $element->settings['type'];
if (($bundleKey = $wrapper
->entityKey('bundle')) && isset($element->settings['param_' . $bundleKey])) {
$element_info['provides']['entity_created']['bundle'] = $element->settings['param_' . $bundleKey];
}
}
}