本文整理汇总了PHP中PMPluginRegistry::loadSingleton方法的典型用法代码示例。如果您正苦于以下问题:PHP PMPluginRegistry::loadSingleton方法的具体用法?PHP PMPluginRegistry::loadSingleton怎么用?PHP PMPluginRegistry::loadSingleton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMPluginRegistry
的用法示例。
在下文中一共展示了PMPluginRegistry::loadSingleton方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: defined
// create memcached singleton
Bootstrap::LoadClass( 'memcached' );
$memcache = & PMmemcached::getSingleton( SYS_SYS );
// load Plugins base class
Bootstrap::LoadClass( 'plugin' );
//here we are loading all plugins registered
//the singleton has a list of enabled plugins
$sSerializedFile = PATH_DATA_SITE . 'plugin.singleton';
if (file_exists( $sSerializedFile )) {
$oPluginRegistry = PMPluginRegistry::loadSingleton($sSerializedFile);
$attributes = $oPluginRegistry->getAttributes();
Bootstrap::LoadTranslationPlugins( defined( 'SYS_LANG' ) ? SYS_LANG : "en" , $attributes);
} else{
$oPluginRegistry = PMPluginRegistry::getSingleton();
}
// setup propel definitions and logging
//changed to autoloader
//require_once ("propel/Propel.php");
//require_once ("creole/Creole.php");
if (defined( 'DEBUG_SQL_LOG' ) && DEBUG_SQL_LOG) {
define( 'PM_PID', mt_rand( 1, 999999 ) );
require_once 'Log.php';
// register debug connection decorator driver
示例2: updatePluginAttributesInAllWorkspaces
/**
* Update the plugin attributes in all workspaces
*
* @param string $pluginName Plugin name
*
* return void
*/
public function updatePluginAttributesInAllWorkspaces($pluginName)
{
try {
G::LoadClass("system");
G::LoadClass("wsTools");
//Set variables
$pluginFileName = $pluginName . ".php";
//Verify data
if (!file_exists(PATH_PLUGINS . $pluginFileName)) {
throw new Exception("Error: The plugin not exists");
}
//Update plugin attributes
require_once(PATH_PLUGINS . $pluginFileName);
$pmPluginRegistry = &PMPluginRegistry::getSingleton();
$pluginDetails = $pmPluginRegistry->getPluginDetails($pluginFileName);
if (isset($pluginDetails->aWorkspaces) && is_array($pluginDetails->aWorkspaces) && count($pluginDetails->aWorkspaces) > 0) {
$arrayWorkspace = array();
foreach (System::listWorkspaces() as $value) {
$workspaceTools = $value;
$arrayWorkspace[] = $workspaceTools->name;
}
$arrayWorkspaceAux = array_diff($arrayWorkspace, $pluginDetails->aWorkspaces); //Workspaces to update
$strWorkspaceNoWritable = "";
$arrayWorkspace = array();
foreach ($arrayWorkspaceAux as $value) {
$workspace = $value;
$workspacePathDataSite = PATH_DATA . "sites" . PATH_SEP . $workspace . PATH_SEP;
if (file_exists($workspacePathDataSite . "plugin.singleton")) {
$pmPluginRegistry = PMPluginRegistry::loadSingleton($workspacePathDataSite . "plugin.singleton");
if (isset($pmPluginRegistry->_aPluginDetails[$pluginName])) {
if (!is_writable($workspacePathDataSite . "plugin.singleton")) {
$strWorkspaceNoWritable .= (($strWorkspaceNoWritable != "")? ", " : "") . $workspace;
}
$arrayWorkspace[] = $workspace;
}
}
}
//Verify data
if ($strWorkspaceNoWritable != "") {
throw new Exception("Error: The workspaces \"$strWorkspaceNoWritable\" has problems of permissions of write in file \"plugin.singleton\", solve this problem");
}
//Update plugin attributes
foreach ($arrayWorkspace as $value) {
$workspace = $value;
$workspacePathDataSite = PATH_DATA . "sites" . PATH_SEP . $workspace . PATH_SEP;
$pmPluginRegistry = PMPluginRegistry::loadSingleton($workspacePathDataSite . "plugin.singleton");
$pmPluginRegistry->disablePlugin($pluginName);
file_put_contents($workspacePathDataSite . "plugin.singleton", $pmPluginRegistry->serializeInstance());
}
}
} catch (Exception $e) {
throw $e;
}
}
示例3: initRest
//.........这里部分代码省略.........
if (file_exists($apiIniFile)) {
$cachedConfig = $this->workspaceCacheDir . "api-config.php";
// verify if config cache file exists, is array and the last modification date is the same when cache was created.
if (!file_exists($cachedConfig) || !is_array($config = (include $cachedConfig)) || $config["_chk"] != filemtime($apiIniFile)) {
$config = Util\Common::parseIniFile($apiIniFile);
$config["_chk"] = filemtime($apiIniFile);
if (!is_dir(dirname($cachedConfig))) {
Util\Common::mk_dir(dirname($cachedConfig));
}
file_put_contents($cachedConfig, "<?php return " . var_export($config, true) . ";");
Util\Logger::log("Configuration cache was loaded and cached to: {$cachedConfig}");
} else {
Util\Logger::log("Loading Api Configuration from: {$cachedConfig}");
}
}
// Setting current workspace to Api class
Services\Api::setWorkspace(SYS_SYS);
$cacheDir = defined("PATH_C") ? PATH_C : sys_get_temp_dir();
$sysConfig = \System::getSystemConfiguration();
\Luracast\Restler\Defaults::$cacheDirectory = $cacheDir;
$productionMode = (bool) (!(isset($sysConfig["service_api_debug"]) && $sysConfig["service_api_debug"]));
Util\Logger::log("Serving API mode: " . ($productionMode ? "production" : "development"));
// create a new Restler instance
//$rest = new \Luracast\Restler\Restler();
$this->rest = new \Maveriks\Extension\Restler($productionMode);
// setting flag for multipart to Restler
$this->rest->setFlagMultipart($multipart);
// setting api version to Restler
$this->rest->setAPIVersion($version);
// adding $authenticationClass to Restler
$this->rest->addAuthenticationClass($authenticationClass, '');
// Setting database connection source
list($host, $port) = strpos(DB_HOST, ':') !== false ? explode(':', DB_HOST) : array(DB_HOST, '');
$port = empty($port) ? '' : ";port={$port}";
Services\OAuth2\Server::setDatabaseSource(DB_USER, DB_PASS, DB_ADAPTER . ":host={$host};dbname=" . DB_NAME . $port);
if (DB_NAME != DB_RBAC_NAME) {
//it's PM < 3
list($host, $port) = strpos(DB_RBAC_HOST, ':') !== false ? explode(':', DB_RBAC_HOST) : array(DB_RBAC_HOST, '');
$port = empty($port) ? '' : ";port={$port}";
Services\OAuth2\Server::setDatabaseSourceRBAC(DB_RBAC_USER, DB_RBAC_PASS, DB_ADAPTER . ":host={$host};dbname=" . DB_RBAC_NAME . $port);
}
// Setting default OAuth Client id, for local PM Web Designer
Services\OAuth2\Server::setPmClientId($pmOauthClientId);
$this->rest->setOverridingFormats('JsonFormat', 'UploadFormat');
// scan all api directory to find api classes
$classesList = Util\Common::rglob($apiDir . "/*");
foreach ($classesList as $classFile) {
if (pathinfo($classFile, PATHINFO_EXTENSION) === 'php') {
$relClassPath = str_replace('.php', '', str_replace($servicesDir, '', $classFile));
$namespace = '\\ProcessMaker\\Services\\' . str_replace(DS, '\\', $relClassPath);
$namespace = strpos($namespace, "//") === false ? $namespace : str_replace("//", '', $namespace);
//if (! class_exists($namespace)) {
require_once $classFile;
//}
$this->rest->addAPIClass($namespace);
}
}
// adding aliases for Restler
if (array_key_exists('alias', $config)) {
foreach ($config['alias'] as $alias => $aliasData) {
if (is_array($aliasData)) {
foreach ($aliasData as $label => $namespace) {
$namespace = '\\' . ltrim($namespace, '\\');
$this->rest->addAPIClass($namespace, $alias);
}
}
}
}
//
// Register API Plugins classes
$isPluginRequest = strpos($uri, '/plugin-') !== false ? true : false;
if ($isPluginRequest) {
$tmp = explode('/', $uri);
array_shift($tmp);
$tmp = array_shift($tmp);
$tmp = explode('-', $tmp);
$pluginName = $tmp[1];
$uri = str_replace('plugin-' . $pluginName, strtolower($pluginName), $uri);
}
// hook to get rest api classes from plugins
if (class_exists('PMPluginRegistry') && file_exists(PATH_DATA_SITE . 'plugin.singleton')) {
$pluginRegistry = \PMPluginRegistry::loadSingleton(PATH_DATA_SITE . 'plugin.singleton');
$plugins = $pluginRegistry->getRegisteredRestServices();
if (!empty($plugins)) {
foreach ($plugins as $pluginName => $plugin) {
$pluginSourceDir = PATH_PLUGINS . $pluginName . DIRECTORY_SEPARATOR . 'src';
$loader = \Maveriks\Util\ClassLoader::getInstance();
$loader->add($pluginSourceDir);
foreach ($plugin as $class) {
if (class_exists($class['namespace'])) {
$this->rest->addAPIClass($class['namespace'], strtolower($pluginName));
}
}
}
}
}
Services\OAuth2\Server::setWorkspace(SYS_SYS);
$this->rest->addAPIClass('\\ProcessMaker\\Services\\OAuth2\\Server', 'oauth2');
return $uri;
}