function _config_pages_features_export_data in Config Pages 7
Extract_fields from given entity.
1 call to _config_pages_features_export_data()
File
- ./
config_pages.features.inc, line 64 - Integrates with features.
Code
function _config_pages_features_export_data($entity_type, $bundle, $entity) {
// Convert to array.
$entity = get_object_vars($entity);
// Build list of supported fields.
$allowed_modules = variable_get('config_pages_features_allowed_modules', array(
'text',
'number',
'list',
'link',
));
$allowed_fields = variable_get('config_pages_features_allowed_fields', array(
'context',
'data',
'type',
'link_field',
));
$fields = field_info_instances($entity_type, $bundle);
foreach ($fields as $field_name => $field_data) {
if (in_array($field_data['widget']['module'], $allowed_modules)) {
$allowed_fields[] = $field_name;
}
}
// Export only allowed fields.
$export = array();
foreach ($entity as $key => $value) {
// Field_collections have special treatement.
if (!empty($fields[$key]) && $fields[$key]['widget']['type'] == 'field_collection_embed' && !empty($value)) {
// We do not support translation by design.
$fc_key = 'field_collection_item:' . $key;
foreach ($value[LANGUAGE_NONE] as $delta => $fcitem) {
$field_collection_item = field_collection_item_load($fcitem['value']);
if ($field_collection_item) {
$export[$fc_key][$delta] = _config_pages_features_export_data('field_collection_item', $key, $field_collection_item);
}
}
}
elseif (in_array($key, $allowed_fields)) {
$export[$key] = $value;
}
}
// Sort for concistency.
ksort($export);
// Return allowed entity export fields.
return $export;
}