Is it possible to define a hook_preprocess function based on entity type such as profile2? I walked through the possible hooks by using function hook_preprocess(&amp;$vars, $hook) and only entity was available to use. Is it possible to do something like hook_preprocess_profile2_entity(), or do I have to write an if condition to check the entity type in hook_preprocess_entity()?
This adapts the Zen theme pattern for node preprocess functions to entities:

&lt;?php

/**
 * Implements template_preprocess_entity().
 *
 * Runs a entity specific preprocess function, if it exists.
 */
function MYTHEME_preprocess_entity(&amp;$variables, $hook) {
  $function = __FUNCTION__ . '_' . $variables['entity_type'];
  if (function_exists($function)) {
    $function($variables, $hook);
  }
}

/**
 * Profile2 specific implementation of template_preprocess_entity().
 */
function MYTHEME_preprocess_entity_profile2(&amp;$variables, $hook) {
}

/**
 * Field Collection specific implementation of template_preprocess_entity().
 */
function MYTHEME_preprocess_entity_field_collection_item(&amp;$variables, $hook) {
}