function _ctools_export_get_defaults in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 includes/export.inc \_ctools_export_get_defaults()
Call the hook to get all default objects of the given type from the export. If configured properly, this could include loading up an API to get default objects.
2 calls to _ctools_export_get_defaults()
- ctools_export_load_object in includes/
export.inc - Load some number of exportable objects.
- ctools_get_default_object in includes/
export.inc - Get the default version of an object, if it exists.
1 string reference to '_ctools_export_get_defaults'
- ctools_export_load_object_reset in includes/
export.inc - Reset all static caches in ctools_export_load_object() or static caches for a given table in ctools_export_load_object().
File
- includes/
export.inc, line 540 - Contains code to make it easier to have exportable objects.
Code
function _ctools_export_get_defaults($table, $export) {
$cache =& ctools_static(__FUNCTION__, array());
if (!isset($cache[$table])) {
$cache[$table] = array();
if ($export['default hook']) {
if (!empty($export['api'])) {
ctools_include('plugins');
$info = ctools_plugin_api_include($export['api']['owner'], $export['api']['api'], $export['api']['minimum_version'], $export['api']['current_version']);
$modules = array_keys($info);
}
else {
$modules = module_implements($export['default hook']);
}
foreach ($modules as $module) {
$function = $module . '_' . $export['default hook'];
if (function_exists($function)) {
foreach ((array) $function($export) as $name => $object) {
// Record the module that provides this exportable.
if (is_object($object)) {
$object->export_module = $module;
}
if (empty($export['api'])) {
$cache[$table][$name] = $object;
}
else {
// If version checking is enabled, ensure that the object can be used.
if (isset($object->api_version) && $object->api_version >= $export['api']['minimum_version'] && $object->api_version <= $export['api']['current_version']) {
$cache[$table][$name] = $object;
}
}
}
}
}
drupal_alter($export['default hook'], $cache[$table]);
}
}
return $cache[$table];
}