function units_unit_machine_name_load in Units of Measurement 7.2
Same name and namespace in other branches
- 7 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
6 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.
- units_mathematical_expression_create_from_infix in ./
units.module - Create mathematical expression object from infix notation.
- units_mathematical_expression_create_from_postfix in ./
units.module - Create mathematical expression object from postfix (reverse polish) notation.
- units_mathematical_expression_load in ./
units.module - Load mathematical expression from database.
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 277 - 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;
}