1 entity.module entity_view_mode_load($entity_type, $machine_name)

Load a custom entity display mode by entity type and machine name.

Parameters

string $entity_type: The entity type of the display mode to be loaded, such as "node", "comment", "user", or "taxonomy_term".

string $machine_name: Machine name of display mode.

Return value

FALSE|array: Array representing the loaded display mode, or FALSE if not found.

File

core/modules/entity/entity.module, line 49
Entity API for handling entities like nodes or users.

Code

function entity_view_mode_load($entity_type, $machine_name) {
  $view_modes = config_get('entity.view_modes', 'view_modes');

  if (!empty($view_modes[$entity_type][$machine_name])) {
    // Ensure that the machine name is always available.
    return $view_modes[$entity_type][$machine_name] + array('machine_name' => $machine_name);
  }
  else {
    $entity_info = entity_get_info($entity_type);
    if (!empty($entity_info['view modes'][$machine_name])) {
      return $entity_info['view modes'][$machine_name] + array('machine_name' => $machine_name);
    }
  }

  return FALSE;
}