function _authcache_flag_extract_entity_from_build in Authenticated User Page Caching (Authcache) 7.2
Extract an actual entity object from its $build array.
This function was shamelessly taken from the eva.module. Kudos to Jeff Eaton!
This is a bit more complicated than it should be, since core entities, contrib entities, and contrib entities based on EntityAPI all store their junk in different slots of the build array. See http://drupal.org/node/1170198.
Parameters
array $build: The render array of an entity.
Return value
object|FALSE The entity extracted from the render array or FALSE.
I hate you, Milkman Dan.
1 call to _authcache_flag_extract_entity_from_build()
- authcache_flag_entity_view_alter in modules/
authcache_flag/ authcache_flag.module - Implements hook_flag_view_alter().
File
- modules/
authcache_flag/ authcache_flag.module, line 169 - Provide personalization for the flag module.
Code
function _authcache_flag_extract_entity_from_build($build) {
// EntityAPI often sticks stuff in here.
if (!empty($build['#entity'])) {
return $build['#entity'];
}
elseif (!empty($build['#' . $build['#entity_type']])) {
return $build['#' . $build['#entity_type']];
}
elseif ($build['#entity_type'] === 'user') {
return $build['#account'];
}
elseif ($build['#entity_type'] === 'taxonomy_term') {
return $build['#term'];
}
return FALSE;
}