You are here

function _ds_check_existing_ui_limit in Display Suite 7.2

Helper function to check if bundle + view_mode combination exists.

1 call to _ds_check_existing_ui_limit()
ds_ui_limit_validate in modules/ds_ui/includes/ds.fields.inc
Element validation function for ui limit field.

File

modules/ds_ui/includes/ds.fields.inc, line 235
Administrative functions for managing custom fields for every entity.

Code

function _ds_check_existing_ui_limit($entity_types, $bundle, $view_mode) {
  $exists = FALSE;
  foreach ($entity_types as $entity_type) {
    $info = entity_get_info($entity_type);

    // Combine allowed bundles and entity specific ones.
    $bundle_allowed = array(
      '*',
    );
    $bundles = array_merge($bundle_allowed, array_keys($info['bundles']));

    // Combine allowed view_modes and entity specific ones.
    $view_mode_allowed = array(
      '*',
      'default',
    );
    $view_modes = array_merge($view_mode_allowed, array_keys($info['view modes']));
    if (in_array($bundle, $bundles) && in_array($view_mode, $view_modes)) {
      $exists = TRUE;
      break;
    }
  }
  if (!$exists) {
    drupal_set_message(t('Incorrect field limit combination: @bundle|@view_mode', array(
      '@bundle' => $bundle,
      '@view_mode' => $view_mode,
    )), 'error');
  }
  return $exists;
}