You are here

function er_viewmode_get_view_modes in Entity reference viewmode selector 7

Fetches view_modes based of the field and instance.

Parameters

$field array - the field definition:

$instance array - the field instance definition:

$ignore_whitelist boolean - if TRUE it will return the full list of available view modes.:

Return value

array - list of view modes

2 calls to er_viewmode_get_view_modes()
ERViewModeBehavior::settingsForm in plugins/behavior/ERViewModeBehavior.class.php
Generate a settings form for this handler.
er_viewmode_field_widget_form_alter in ./er_viewmode.module
Implements hook_field_widget_form_alter().

File

./er_viewmode.module, line 50

Code

function er_viewmode_get_view_modes($field, $instance, $ignore_whitelist = FALSE) {
  $target_type = $field['settings']['target_type'];
  $entity_info = entity_get_info($target_type);
  $view_modes = array(
    'full' => 'Default',
  );
  foreach ($entity_info['view modes'] as $view_key => $view_mode) {
    if ($ignore_whitelist || !empty($field['settings']['handler_settings']['behaviors']['er_viewmode_behavior']['enabled_viewmodes'][$view_key])) {
      $view_modes[$view_key] = $view_mode['label'];
    }
  }
  if (!$ignore_whitelist) {
    drupal_alter('er_viewmode_get_view_modes', $view_modes, $field, $instance);
  }
  return $view_modes;
}