function _tmgmt_plugin_controller in Translation Management Tool 7
Determines the controller class for a given plugin type.
Parameters
$type: The type of the plugin. Can be 'translator' or 'source'.
$plugin: (Optional) The machine-readable name of a source plugin.
Return value
TMGMTPluginBaseInterface The controller object for the given plugin or an array containing all available plugin controller objects if no plugin name was given.
6 calls to _tmgmt_plugin_controller()
- tmgmt_file_format_controller in translators/
file/ tmgmt_file.module - Returns the file format plugin controller.
- tmgmt_source_plugin_controller in ./
tmgmt.module - Get the plugin controller class for a given source plugin.
- tmgmt_source_ui_controller in ./
tmgmt.module - Get the ui controller class for a given source plugin.
- tmgmt_source_views_controller in ./
tmgmt.module - Get the views controller class for a given source plugin.
- tmgmt_translator_plugin_controller in ./
tmgmt.module - Determines the controller class for a given service plugin.
1 string reference to '_tmgmt_plugin_controller'
- TMGMTI18nStringSourceTestCase::testI18nStringSourceMenu in sources/
i18n_string/ tmgmt_i18n_string.test
File
- ./
tmgmt.module, line 1265 - Main module file for the Translation Management module.
Code
function _tmgmt_plugin_controller($type, $plugin = NULL, $controller = 'plugin', $default = NULL) {
$key = $controller . ' controller class';
$cache =& drupal_static(__FUNCTION__);
if (!isset($plugin) && !isset($cache[$type][$controller])) {
$cache[$type][$controller] = array();
foreach (_tmgmt_plugin_info($type) as $name => $info) {
if (!isset($cache[$type][$controller][$name])) {
$class = isset($default) && !isset($info[$key]) ? $default : $info[$key];
$cache[$type][$controller][$name] = new $class($type, $name);
}
}
}
elseif (isset($plugin) && !isset($cache[$type][$controller][$plugin])) {
$info = _tmgmt_plugin_info($type, $plugin);
if (empty($info[$key]) && empty($default)) {
$cache[$type][$controller][$plugin] = FALSE;
}
else {
$class = empty($info[$key]) ? $default : $info[$key];
$cache[$type][$controller][$plugin] = new $class($type, $plugin);
}
}
if (isset($plugin)) {
return $cache[$type][$controller][$plugin];
}
else {
return array_filter($cache[$type][$controller]);
}
}