function ctools_plugin_get_function in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 includes/plugins.inc \ctools_plugin_get_function()
Get a function from a plugin, if it exists. If the plugin is not already loaded, try ctools_plugin_load_function() instead.
Parameters
$plugin_definition: The loaded plugin type.
$function_name: The identifier of the function. For example, 'settings form'.
Return value
The actual name of the function to call, or NULL if the function does not exist.
44 calls to ctools_plugin_get_function()
- ctools_access in includes/
context.inc - Determine if the current user has access via plugin.
- ctools_access_add_restrictions in includes/
context.inc - Apply restrictions to contexts based upon the access control configured.
- ctools_access_ajax_edit_item in includes/
context-access-admin.inc - Form to edit the settings of an access test.
- ctools_access_ajax_edit_item_submit in includes/
context-access-admin.inc - Submit handler for argument settings.
- ctools_access_ajax_edit_item_validate in includes/
context-access-admin.inc - Validate handler for argument settings.
File
- includes/
plugins.inc, line 668 - 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_get_function($plugin_definition, $function_name) {
// If cached the .inc file may not have been loaded. require_once is quite safe
// and fast so it's okay to keep calling it.
if (isset($plugin_definition['file'])) {
// Plugins that are loaded from info files have the info file as
// $plugin['file']. Don't try to run those.
$info = ctools_plugin_get_info($plugin_definition['plugin module'], $plugin_definition['plugin type']);
if (empty($info['info file'])) {
require_once './' . $plugin_definition['path'] . '/' . $plugin_definition['file'];
}
}
if (!isset($plugin_definition[$function_name])) {
return;
}
if (is_array($plugin_definition[$function_name]) && isset($plugin_definition[$function_name]['function'])) {
$function = $plugin_definition[$function_name]['function'];
if (isset($plugin_definition[$function_name]['file'])) {
$file = $plugin_definition[$function_name]['file'];
if (isset($plugin_definition[$function_name]['path'])) {
$file = $plugin_definition[$function_name]['path'] . '/' . $file;
}
require_once './' . $file;
}
}
else {
$function = $plugin_definition[$function_name];
}
if (function_exists($function)) {
return $function;
}
}