function _redhen_dedupe_set_field_collection_value in RedHen CRM 7
Helper function for setting stubborn field collection fields.
1 call to _redhen_dedupe_set_field_collection_value()
- redhen_dedupe_merge in modules/
redhen_dedupe/ redhen_dedupe.module - Merge values from contacts into master contact and handle related entities.
File
- modules/
redhen_dedupe/ redhen_dedupe.module, line 412
Code
function _redhen_dedupe_set_field_collection_value($entity, $field, $value) {
$fc_item = entity_create('field_collection_item', array(
'field_name' => $field,
));
$fc_item
->setHostEntity('redhen_contact', $entity);
$fc_item_wrapper = entity_metadata_wrapper('field_collection_item', $fc_item);
$val_wrapper = entity_metadata_wrapper('field_collection_item', $value);
$val_properties = $val_wrapper
->getPropertyInfo();
foreach ($val_properties as $property => $prop_details) {
if (isset($prop_details['field']) && $prop_details['field']) {
//} && ($val_wrapper->{$property}->value() != NULL)) {
//@todo support multi-value fields needed?
//@todo support additional field collections?
$fc_item_wrapper->{$property}
->set($val_wrapper->{$property}
->value());
}
}
}