本文整理汇总了PHP中PluginRegistry::_instantiatePlugin方法的典型用法代码示例。如果您正苦于以下问题:PHP PluginRegistry::_instantiatePlugin方法的具体用法?PHP PluginRegistry::_instantiatePlugin怎么用?PHP PluginRegistry::_instantiatePlugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PluginRegistry
的用法示例。
在下文中一共展示了PluginRegistry::_instantiatePlugin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Load all plugins for a given category.
* @param $category string The name of the category to load
* @param $enabledOnly boolean if true load only enabled
* plug-ins (db-installation required), otherwise look on
* disk and load all available plug-ins (no db required).
* @param $mainContextId integer To identify enabled plug-ins
* we need a context. This context is usually taken from the
* request but sometimes there is no context in the request
* (e.g. when executing CLI commands). Then the main context
* can be given as an explicit ID.
*/
function &loadCategory($category, $enabledOnly = false, $mainContextId = null)
{
$plugins = array();
$categoryDir = PLUGINS_PREFIX . $category;
if (!is_dir($categoryDir)) {
return $plugins;
}
if ($enabledOnly && Config::getVar('general', 'installed')) {
// Get enabled plug-ins from the database.
$application =& PKPApplication::getApplication();
$products =& $application->getEnabledProducts('plugins.' . $category, $mainContextId);
foreach ($products as $product) {
$file = $product->getProduct();
$plugin =& PluginRegistry::_instantiatePlugin($category, $categoryDir, $file, $product->getProductClassname());
if ($plugin && is_object($plugin)) {
$plugins[$plugin->getSeq()]["{$categoryDir}/{$file}"] =& $plugin;
unset($plugin);
}
}
} else {
// Get all plug-ins from disk. This does not require
// any database access and can therefore be used during
// first-time installation.
$handle = opendir($categoryDir);
while (($file = readdir($handle)) !== false) {
if ($file == '.' || $file == '..') {
continue;
}
$plugin =& PluginRegistry::_instantiatePlugin($category, $categoryDir, $file);
if ($plugin && is_object($plugin)) {
$plugins[$plugin->getSeq()]["{$categoryDir}/{$file}"] =& $plugin;
unset($plugin);
}
}
closedir($handle);
}
// If anyone else wants to jump category, here is the chance.
HookRegistry::call('PluginRegistry::loadCategory', array(&$category, &$plugins));
// Register the plugins in sequence.
ksort($plugins);
foreach ($plugins as $seq => $junk1) {
foreach ($plugins[$seq] as $pluginPath => $junk2) {
PluginRegistry::register($category, $plugins[$seq][$pluginPath], $pluginPath);
}
}
unset($plugins);
// Return the list of successfully-registered plugins.
$plugins =& PluginRegistry::getPlugins($category);
return $plugins;
}