當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PluginRegistry::_instantiatePlugin方法代碼示例

本文整理匯總了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;
 }
開發者ID:farhanabbas1983,項目名稱:ojs-1,代碼行數:62,代碼來源:PluginRegistry.inc.php


注:本文中的PluginRegistry::_instantiatePlugin方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。