function menu_fields_load_by_mlid in Menu Item Fields 7
Gets the Menu Fields entity for given Menu Link ID.
Parameters
int $mlid: The Menu Link ID to search for the fields entity.
Return value
Entity The entity or NULL is no entity found.
1 call to menu_fields_load_by_mlid()
- menu_fields_preprocess_menu_link in ./
menu_fields.module - Menu fields link function.
File
- ./
menu_fields.module, line 833 - Main file contain hooks/functions.
Code
function menu_fields_load_by_mlid($mlid) {
$cache_key = 'fields:mlid:' . $mlid;
$entity =& drupal_static($cache_key);
// Check the cache for this entity.
if (!$entity) {
$entity = cache_get($cache_key, 'cache_menu_fields');
$entity = $entity ? $entity->data : NULL;
}
// If the entity is not cached, load it.
if (!$entity) {
// Get the menu link from given mlid.
$id = menu_fields_entity_id_by_mlid($mlid);
if ($id) {
$entity = entity_load_single('menu_fields', $id);
cache_set($cache_key, $entity, 'cache_menu_fields');
}
}
return $entity;
}