function ctools_plugin_api_include in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 includes/plugins.inc \ctools_plugin_api_include()
Load a group of API files.
This will ask each module if they support the given API, and if they do it will load the specified file name. The API and the file name coincide by design.
Parameters
$owner: The name of the module that controls the API.
$api: The name of the api. The api name forms the file name: $module.$api.inc, though this can be overridden by the module's response.
$minimum_version: The lowest version API that is compatible with this one. If a module reports its API as older than this, its files will not be loaded. This should never change during operation.
$current_version: The current version of the api. If a module reports its minimum API as higher than this, its files will not be loaded. This should never change during operation.
Return value
The API information, in case you need it.
1 call to ctools_plugin_api_include()
- _ctools_export_get_defaults in includes/
export.inc - 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.
File
- includes/
plugins.inc, line 127 - Contains routines to organize and load plugins. It allows a special variation of the hook system so that plugins can be kept in separate .inc files, and can be either loaded all at once or loaded only when necessary.
Code
function ctools_plugin_api_include($owner, $api, $minimum_version, $current_version) {
static $already_done = array();
$info = ctools_plugin_api_info($owner, $api, $minimum_version, $current_version);
if (!isset($already_done[$owner][$api])) {
foreach ($info as $module => $plugin_info) {
if (!isset($plugin_info['file'])) {
$plugin_info['file'] = "{$module}.{$api}.inc";
}
if (file_exists("./{$plugin_info['path']}/{$plugin_info['file']}")) {
$plugin_info[$module]['included'] = TRUE;
require_once "./{$plugin_info['path']}/{$plugin_info['file']}";
}
$info[$module] = $plugin_info;
}
$already_done[$owner][$api] = TRUE;
}
return $info;
}