function units_unit_machine_name_load in Units of Measurement 7
Same name and namespace in other branches
- 7.2 units.module \units_unit_machine_name_load()
Load a single entity of type 'units_unit' loading by its machine name.
Parameters
string $machine_name: Machine name of entity to load
Return value
object|bool Return fully loaded entity object if it was found, otherwise FALSE
2 calls to units_unit_machine_name_load()
- UnitsDefaultWebTestCase::testDefaultEntities in units_default/
units_default.test - Conduct testing of enabling/disabling default units.
- UnitsWebTestCase::testCrud in ./
units.test - Conduct testing of CRUD operations.
1 string reference to 'units_unit_machine_name_load'
- units_unit_form in ./
units_ui.pages.inc - Generate editing form for entity type 'units_unit'.
File
- ./
units.module, line 245 - Provide API for managing and converting units of measurement.
Code
function units_unit_machine_name_load($machine_name) {
$query = new EntityFieldQuery();
$result = $query
->entityCondition('entity_type', 'units_unit')
->propertyCondition('machine_name', $machine_name)
->execute();
if (isset($result['units_unit'])) {
$keys = array_keys($result['units_unit']);
$entity_id = array_pop($keys);
return units_unit_load($entity_id);
}
// No entity was found.
return FALSE;
}