function mvf_measure_extract in Measured Value Field 7
Extract 'units_measure' entity from a MVF field.
Parameters
array $field: Field definition array of a MVF field
Return value
object Fully loaded 'units_measure' entity that is used in the provided MVF field
7 calls to mvf_measure_extract()
- mvf_devel_generate in ./
mvf.devel_generate.inc - Generate dummy values for MVF field.
- mvf_feeds_set_target in ./
mvf.feeds.inc - MVF callback for mapping.
- mvf_field_delete_instance in ./
mvf.module - Implements hook_field_delete_instance().
- mvf_field_update_instance in ./
mvf.module - Implements hook_field_update_instance().
- mvf_property_info_alter in ./
mvf.module - Property info alter callback for MVF field structure.
File
- ./
mvf.module, line 1769 - Define a field type of measured value.
Code
function mvf_measure_extract($field) {
$mocked_field = mvf_field_mockup($field, 'unit');
$options = entityreference_get_selection_handler($mocked_field)
->getReferencableEntities(NULL, 'CONTAINS', 1);
if (!empty($options)) {
$bundles = array_keys($options);
return units_measure_machine_name_load(reset($bundles));
}
return NULL;
}