You are here

function ctools_get_default_object in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/export.inc \ctools_get_default_object()

Get the default version of an object, if it exists.

This function doesn't care if an object is in the database or not and does not check. This means that export_type could appear to be incorrect, because a version could exist in the database. However, it's not incorrect for this function as it is *only* used for the default in code version.

File

includes/export.inc, line 505
Contains code to make it easier to have exportable objects.

Code

function ctools_get_default_object($table, $name) {
  $schema = ctools_export_get_schema($table);
  $export = $schema['export'];
  if (!$export['default hook']) {
    return;
  }

  // @todo add a method to load .inc files for this.
  $defaults = _ctools_export_get_defaults($table, $export);
  $status = variable_get($export['status'], array());
  if (!isset($defaults[$name])) {
    return;
  }
  $object = $defaults[$name];

  // Determine if default object is enabled or disabled.
  if (isset($status[$object->{$export['key']}])) {
    $object->disabled = $status[$object->{$export['key']}];
  }
  $object->{$export['export type string']} = t('Default');
  $object->export_type = EXPORT_IN_CODE;
  $object->in_code_only = TRUE;
  return $object;
}