本文整理汇总了PHP中Q_Config::clear方法的典型用法代码示例。如果您正苦于以下问题:PHP Q_Config::clear方法的具体用法?PHP Q_Config::clear怎么用?PHP Q_Config::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Q_Config
的用法示例。
在下文中一共展示了Q_Config::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configure
/**
* Loads the configuration and plugins in the right order
* @method configure
* @static
* @param boolean [$force_reload=false] If true, forces the reload of the cache.
* Otherwise it happens only if Q/configServer/interval seconds
* have passed since the last time.
* @throws {Q_Exception_MissingPlugin}
*/
static function configure($force_reload = false)
{
$app_tree = new Q_Tree();
// check if config need to be reloaded
if (Q_Cache::connected()) {
// we need to know reload interval
$app_tree->load('config/Q.json');
$app_tree->load('config/app.json');
$app_tree->load('local/app.json');
$config_files = $app_tree->get('Q', 'configFiles', array());
foreach ($config_files as $cf) {
$app_tree->merge(Q_Config::getFromServer($cf));
}
// second round to catch configFiles inside configFiles
$config_files = $app_tree->get('Q', 'configFiles', array());
foreach ($config_files as $cf) {
$app_tree->merge(Q_Config::getFromServer($cf));
}
$interval = $app_tree->get('Q', 'configServer', 'interval', 60);
// reload each minute by default
$app_tree->clear(null);
$timestamp = Q_Cache::get("Q_Config\tupdate_time");
if (!isset($timestamp) || time() - $timestamp > $interval) {
$force_reload = true;
}
}
if ($force_reload) {
$old_setting = Q_Cache::ignore(true);
}
Q_Config::clear(null);
// clear the config
Q_Config::load('config/Q.json');
// Get the app config, but don't load it yet
$app_tree->load('config/app.json');
$app_tree->load('local/app.json');
// Load all the plugin config files first
$paths = explode(PS, get_include_path());
$plugins = $app_tree->get('Q', 'plugins', array());
if (!in_array('Q', $plugins)) {
array_unshift($plugins, 'Q');
}
global $Q_Bootstrap_config_plugin_limit;
$i = 0;
foreach ($plugins as $k => $v) {
++$i;
if (isset($Q_Bootstrap_config_plugin_limit) and $i > $Q_Bootstrap_config_plugin_limit) {
continue;
}
$plugin = is_numeric($k) ? $v : $k;
$plugin_path = Q::realPath('plugins' . DS . $v);
if (!$plugin_path) {
throw new Q_Exception_MissingPlugin(compact('plugin'));
}
Q_Config::load($plugin_path . DS . 'config' . DS . 'plugin.json');
array_splice($paths, 1, 0, array($plugin_path));
$PLUGIN = strtoupper($plugin);
if (!defined($PLUGIN . '_PLUGIN_DIR')) {
define($PLUGIN . '_PLUGIN_DIR', $plugin_path);
}
if (!defined($PLUGIN . '_PLUGIN_CONFIG_DIR')) {
define($PLUGIN . '_PLUGIN_CONFIG_DIR', $plugin_path . DS . 'config');
}
if (!defined($PLUGIN . '_PLUGIN_CLASSES_DIR')) {
define($PLUGIN . '_PLUGIN_CLASSES_DIR', $plugin_path . DS . 'classes');
}
if (!defined($PLUGIN . '_PLUGIN_FILES_DIR')) {
define($PLUGIN . '_PLUGIN_FILES_DIR', $plugin_path . DS . 'files');
}
if (!defined($PLUGIN . '_PLUGIN_HANDLERS_DIR')) {
define($PLUGIN . '_PLUGIN_HANDLERS_DIR', $plugin_path . DS . 'handlers');
}
if (!defined($PLUGIN . '_PLUGIN_PLUGINS_DIR')) {
define($PLUGIN . '_PLUGIN_PLUGINS_DIR', $plugin_path . DS . 'plugins');
}
if (!defined($PLUGIN . '_PLUGIN_SCRIPTS_DIR')) {
define($PLUGIN . '_PLUGIN_SCRIPTS_DIR', $plugin_path . DS . 'scripts');
}
if (!defined($PLUGIN . '_PLUGIN_VIEWS_DIR')) {
define($PLUGIN . '_PLUGIN_VIEWS_DIR', $plugin_path . DS . 'views');
}
if (!defined($PLUGIN . '_PLUGIN_TESTS_DIR')) {
define($PLUGIN . '_PLUGIN_TESTS_DIR', $plugin_path . DS . 'tests');
}
if (!defined($PLUGIN . '_PLUGIN_WEB_DIR')) {
define($PLUGIN . '_PLUGIN_WEB_DIR', $plugin_path . DS . 'web');
}
self::$plugins[$plugin] = $plugin_path;
}
$paths = array_unique($paths);
set_include_path(implode(PS, $paths));
// Now, we can merge in our app's config
//.........这里部分代码省略.........