Пример #1
0
const char* Config::Get(const IniSetting::Map &ini, const Hdf& config,
                        const std::string& name /* = "" */,
                        const char *defValue /* = nullptr */,
                        const bool prepend_hhvm /* = true */) {
  auto ini_name = IniName(name, prepend_hhvm);
  Hdf hdf = name != "" ? config[name] : config;
  auto* value = ini_iterate(ini, ini_name);
  if (value && value->isString()) {
    // See generic Get##METHOD below for why we are doing this
    const char* ini_ret = value->data();
    const char* hdf_ret = hdf.configGet(value->data());
    if (hdf_ret != ini_ret) {
      ini_ret = hdf_ret;
      IniSetting::Set(ini_name, ini_ret);
    }
    return ini_ret;
  }
  return hdf.configGet(defValue);
}
Пример #2
0
// This method must return a char* which is owned by the IniSettingMap
// to avoid issues with the lifetime of the char*
const char* Config::Get(const IniSettingMap &ini, const Hdf& config,
                        const std::string& name /* = "" */,
                        const char *defValue /* = nullptr */,
                        const bool prepend_hhvm /* = true */) {
  auto ini_name = IniName(name, prepend_hhvm);
  Hdf hdf = name != "" ? config[name] : config;
  auto value = ini_iterate(ini, ini_name);
  if (value.isString()) {
    // See generic Get##METHOD below for why we are doing this
    // Note that value is a string, so value.toString() is not
    // a temporary.
    const char* ini_ret = value.toString().data();
    const char* hdf_ret = hdf.configGet(ini_ret);
    if (hdf_ret != ini_ret) {
      ini_ret = hdf_ret;
      IniSetting::SetSystem(ini_name, ini_ret);
    }
    return ini_ret;
  }
  return hdf.configGet(defValue);
}
Пример #3
0
void Config::Bind(std::vector<std::string>& loc, const IniSettingMap& ini,
                  const Hdf& config) {
  std::vector<std::string> ret;
  auto ini_name = IniName(config);
  auto* value = ini.get_ptr(ini_name);
  if (value && value->isObject()) {
    ini_on_update(*value, ret);
    loc = ret;
  }
  // If there is an HDF setting for the config, then it still wins for
  // the RuntimeOption value until we obliterate HDFs
  ret.clear();
  config.configGet(ret);
  if (ret.size() > 0) {
    loc = ret;
  }
  IniSetting::Bind(IniSetting::CORE, IniSetting::PHP_INI_SYSTEM, ini_name,
                   &loc);
}