You are here

function ds_get_field_settings in Display Suite 7.2

Same name and namespace in other branches
  1. 7 ds.module \ds_get_field_settings()

Get the field settings.

Parameters

$entity_type: The name of the entity.

$bundle: The name of bundle (ie, page or story for node types, profile for users)

$view_mode: The name of view mode.

5 calls to ds_get_field_settings()
dsLayoutsClassesTests::testDStestLayouts in tests/ds.base.test
Test selecting layouts, classes, region to block and fields.
ds_extras_preprocess_field in modules/ds_extras/ds_extras.module
Implements hook_preprocess_field().
ds_field_attach_view_alter in ./ds.module
Implements hook_field_attach_view_alter().
node_ds_search_execute in modules/ds_search/ds_search.module
Search on behalf of Drupal Core.
_ds_field_ui_fields in includes/ds.field_ui.inc
Add the fields to the Field UI form.

File

./ds.module, line 371
Display Suite core functions.

Code

function ds_get_field_settings($entity_type, $bundle, $view_mode, $default = TRUE) {
  static $field_settings = NULL;
  if (!isset($field_settings)) {
    if ($cache = cache_get('ds_field_settings')) {
      $field_settings = $cache->data;
    }
    else {
      ctools_include('export');
      $ds_field_settings = ctools_export_crud_load_all('ds_field_settings');
      foreach ($ds_field_settings as $layout => $layout_settings) {

        // Do not store configuration when the field settings is disabled.
        if (!empty($layout_settings->disabled)) {
          continue;
        }

        // Do not store configuration if settings key is not set.
        if (!isset($layout_settings->settings)) {
          continue;
        }
        foreach ($layout_settings->settings as $field => $settings) {
          $field_settings[$layout_settings->entity_type][$layout_settings->bundle][$layout_settings->view_mode][$field] = $settings;
        }
      }
      cache_set('ds_field_settings', $field_settings, 'cache');
    }
  }
  return isset($field_settings[$entity_type][$bundle][$view_mode]) ? $field_settings[$entity_type][$bundle][$view_mode] : (isset($field_settings[$entity_type][$bundle]['default']) && $default ? $field_settings[$entity_type][$bundle]['default'] : array());
}