function properties_extract_fields in Dynamic properties 7
Extracts properties fields from entity.
2 calls to properties_extract_fields()
- properties_compare_is_comparable in properties_compare/
properties_compare.module - Checks if two entites can be compared.
- properties_compare_page in properties_compare/
properties_compare.pages.inc - Page callback, display comparison table.
File
- ./
properties.module, line 950 - This module provides a dynamic property field that can contain an unlimited number of attribute value pairs.
Code
function properties_extract_fields($entity_type, $entity) {
$properties_fields = array();
// Load fields attached to the entity.
$fields = field_info_instances($entity_type, field_extract_bundle($entity_type, $entity));
// Get the display language for the entity.
$languages = field_language($entity_type, $entity);
// Loop over fields.
foreach ($fields as $field_name => $field) {
$field_info = field_info_field_by_id($field['field_id']);
// Only handle properties fields.
if ($field_info['type'] == 'properties') {
// Load content for the configured language.
$field_all_languages = $entity->{$field_name};
// Field is empty.
if (empty($field_all_languages) || !isset($field_all_languages[$languages[$field_name]])) {
continue;
}
$properties_fields[$field_name] = $field_all_languages[$languages[$field_name]];
}
}
return $properties_fields;
}