function ctools_plugin_api_include in Chaos Tool Suite (ctools) 7
Same name and namespace in other branches
- 6 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 - Get export object defaults.
File
- includes/
plugins.inc, line 144 - 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);
foreach ($info as $module => $plugin_info) {
if (!isset($already_done[$owner][$api][$module])) {
if (isset($plugin_info["{$api} file"])) {
$file = $plugin_info["{$api} file"];
}
elseif (isset($plugin_info['file'])) {
$file = $plugin_info['file'];
}
else {
$file = "{$module}.{$api}.inc";
}
if (file_exists(DRUPAL_ROOT . "/{$plugin_info['path']}/{$file}")) {
require_once DRUPAL_ROOT . "/{$plugin_info['path']}/{$file}";
}
elseif (file_exists(DRUPAL_ROOT . "/{$file}")) {
require_once DRUPAL_ROOT . "/{$file}";
}
$already_done[$owner][$api][$module] = TRUE;
}
}
return $info;
}