当前位置: 首页>>代码示例>>PHP>>正文


PHP Q_Config::getFromServer方法代码示例

本文整理汇总了PHP中Q_Config::getFromServer方法的典型用法代码示例。如果您正苦于以下问题:PHP Q_Config::getFromServer方法的具体用法?PHP Q_Config::getFromServer怎么用?PHP Q_Config::getFromServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Q_Config的用法示例。


在下文中一共展示了Q_Config::getFromServer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Q_Config_post

/**
 * Handle different tasks related to Q config
 */
function Q_Config_post()
{
    switch (isset($_REQUEST['Q/method']) ? $_REQUEST['Q/method'] : null) {
        case 'clear':
            if (!isset($_REQUEST['filename'])) {
                throw new Q_Exception("'filename' is not defined in 'clear', 'Q/config' handler");
            } else {
                $filename = $_REQUEST['filename'];
            }
            if (!isset($_REQUEST['args'])) {
                throw new Q_Exception("'args' is not defined in 'clear', 'Q/config' handler");
            } else {
                $args = $_REQUEST['args'];
            }
            if (!isset($_REQUEST['noSave'])) {
                throw new Q_Exception("'noSave' is not defined in 'clear', 'Q/config' handler");
            } else {
                $noSave = $_REQUEST['noSave'];
            }
            Q_Config::$cache = Q_Config::clearOnServer($filename, $args, $noSave);
            break;
        case 'set':
            if (!isset($_REQUEST['filename'])) {
                throw new Q_Exception("'filename' is not defined in 'set', 'Q/config' handler");
            } else {
                $filename = $_REQUEST['filename'];
            }
            if (!isset($_REQUEST['data'])) {
                throw new Q_Exception("'data' is not defined in 'set', 'Q/config' handler");
            } else {
                $data = $_REQUEST['data'];
            }
            if (!isset($_REQUEST['clear'])) {
                throw new Q_Exception("'clear' is not defined in 'set', 'Q/config' handler");
            } else {
                $clear = $_REQUEST['clear'];
            }
            Q_Config::$cache = Q_Config::setOnServer($filename, $data, $clear);
            break;
        case 'get':
            if (!isset($_REQUEST['filename'])) {
                throw new Q_Exception("'filename' is not defined in 'put', 'Q/config' handler");
            } else {
                $filename = $_REQUEST['filename'];
            }
            Q_Config::$cache = Q_Config::getFromServer($filename);
            break;
        default:
            throw new Q_Exception("Unknown 'Q/method' in 'Q/config' handler");
            break;
    }
}
开发者ID:dmitriz,项目名称:Platform,代码行数:55,代码来源:post.php

示例2: 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
//.........这里部分代码省略.........
开发者ID:atirjavid,项目名称:Platform,代码行数:101,代码来源:Bootstrap.php


注:本文中的Q_Config::getFromServer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。