本文整理汇总了PHP中rex::setConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP rex::setConfig方法的具体用法?PHP rex::setConfig怎么用?PHP rex::setConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rex
的用法示例。
在下文中一共展示了rex::setConfig方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRexConfig
public function testRexConfig()
{
$key = 'aTestKey';
// initial test on empty config
$this->assertFalse(rex::hasConfig($key), 'the key does not exists at first');
$this->assertNull(rex::getConfig($key), 'getting non existing key returns null');
$this->assertEquals(rex::getConfig($key, 'defVal'), 'defVal', 'getting non existing key returns a given default');
$this->assertFalse(rex::removeConfig($key), 'remove non existing key returns false');
// test after setting a value
$this->assertFalse(rex::setConfig($key, 'aVal'), 'setting non-existant value returns false');
$this->assertEquals(rex::getConfig($key, 'defVal'), 'aVal', 'getting existing key returns its value');
$this->assertTrue(rex::hasConfig($key), 'setted value exists');
// test after re-setting a value
$this->assertTrue(rex::setConfig($key, 'aOtherVal'), 're-setting a value returns true');
$this->assertEquals(rex::getConfig($key, 'defaOtherVal'), 'aOtherVal', 'getting existing key returns its value');
// test after cleanup
$this->assertTrue(rex::removeConfig($key), 'remove a existing key returns true');
$this->assertFalse(rex::hasConfig($key), 'the key does not exists after removal');
$this->assertNull(rex::getConfig($key), 'getting non existing key returns null');
$this->assertEquals(rex::getConfig($key, 'defVal'), 'defVal', 'getting non existing key returns a given default');
}
示例2: synchronizeWithFileSystem
/**
* Synchronizes the packages with the file system.
*/
public static function synchronizeWithFileSystem()
{
$config = rex::getConfig('package-config');
$addons = self::readPackageFolder(rex_path::src('addons'));
$registeredAddons = array_keys(rex_addon::getRegisteredAddons());
foreach (array_diff($registeredAddons, $addons) as $addonName) {
$manager = rex_addon_manager::factory(rex_addon::get($addonName));
$manager->_delete(true);
unset($config[$addonName]);
}
foreach ($addons as $addonName) {
if (!rex_addon::exists($addonName)) {
$config[$addonName]['install'] = false;
$config[$addonName]['status'] = false;
$registeredPlugins = [];
} else {
$addon = rex_addon::get($addonName);
$config[$addonName]['install'] = $addon->isInstalled();
$config[$addonName]['status'] = $addon->isAvailable();
$registeredPlugins = array_keys($addon->getRegisteredPlugins());
}
$plugins = self::readPackageFolder(rex_path::addon($addonName, 'plugins'));
foreach (array_diff($registeredPlugins, $plugins) as $pluginName) {
$manager = rex_plugin_manager::factory(rex_plugin::get($addonName, $pluginName));
$manager->_delete(true);
unset($config[$addonName]['plugins'][$pluginName]);
}
foreach ($plugins as $pluginName) {
$plugin = rex_plugin::get($addonName, $pluginName);
$config[$addonName]['plugins'][$pluginName]['install'] = $plugin->isInstalled();
$config[$addonName]['plugins'][$pluginName]['status'] = $plugin->getProperty('status');
}
if (isset($config[$addonName]['plugins']) && is_array($config[$addonName]['plugins'])) {
ksort($config[$addonName]['plugins']);
}
}
ksort($config);
rex::setConfig('package-config', $config);
rex_addon::initialize();
}
示例3: execute
//.........这里部分代码省略.........
}
}
}
//$config = rex_file::getConfig($temppath . 'core/default.config.yml');
//foreach ($config['system_addons'] as $addonkey) {
// if (is_dir($temppath . 'addons/' . $addonkey) && rex_addon::exists($addonkey)) {
// $updateAddons[$addonkey] = rex_addon::get($addonkey);
// }
//}
$this->checkRequirements($temppath, $version['version'], $updateAddonsConfig);
if (file_exists($temppath . 'core/update.php')) {
include $temppath . 'core/update.php';
}
foreach ($updateAddons as $addonkey => $addon) {
if ($addon->isInstalled() && file_exists($file = $temppath . 'addons/' . $addonkey . '/' . rex_package::FILE_UPDATE)) {
try {
$addon->includeFile($file);
if ($msg = $addon->getProperty('updatemsg', '')) {
throw new rex_functional_exception($msg);
}
if (!$addon->getProperty('update', true)) {
throw new rex_functional_exception(rex_i18n::msg('package_no_reason'));
}
} catch (rex_functional_exception $e) {
throw new rex_functional_exception($addonkey . ': ' . $e->getMessage(), $e);
} catch (rex_sql_exception $e) {
throw new rex_functional_exception($addonkey . ': SQL error: ' . $e->getMessage(), $e);
}
}
}
// create backup
$installConfig = rex_file::getCache($installAddon->getDataPath('config.json'));
if (isset($installConfig['backups']) && $installConfig['backups']) {
rex_dir::create($installAddon->getDataPath());
$archive = $installAddon->getDataPath(strtolower(preg_replace('/[^a-z0-9-_.]/i', '_', rex::getVersion())) . '.zip');
rex_install_archive::copyDirToArchive(rex_path::core(), $archive);
foreach ($updateAddons as $addonkey => $addon) {
rex_install_archive::copyDirToArchive($addon->getPath(), $archive, 'addons/' . $addonkey);
}
}
// copy plugins to new addon dirs
foreach ($updateAddons as $addonkey => $addon) {
foreach ($addon->getRegisteredPlugins() as $plugin) {
$pluginPath = $temppath . 'addons/' . $addonkey . '/plugins/' . $plugin->getName();
if (!is_dir($pluginPath)) {
rex_dir::copy($plugin->getPath(), $pluginPath);
} elseif ($plugin->isInstalled() && is_dir($pluginPath . '/assets')) {
rex_dir::copy($pluginPath . '/assets', $plugin->getAssetsPath());
}
}
}
// move temp dirs to permanent destination
rex_dir::delete(rex_path::core());
rename($temppath . 'core', rex_path::core());
if (is_dir(rex_path::core('assets'))) {
rex_dir::copy(rex_path::core('assets'), rex_path::coreAssets());
}
foreach ($coreAddons as $addonkey) {
if (isset($updateAddons[$addonkey])) {
rex_dir::delete(rex_path::addon($addonkey));
}
rename($temppath . 'addons/' . $addonkey, rex_path::addon($addonkey));
if (is_dir(rex_path::addon($addonkey, 'assets'))) {
rex_dir::copy(rex_path::addon($addonkey, 'assets'), rex_path::addonAssets($addonkey));
}
}
} catch (rex_functional_exception $e) {
$message = $e->getMessage();
} catch (rex_sql_exception $e) {
$message = 'SQL error: ' . $e->getMessage();
}
rex_file::delete($archivefile);
rex_dir::delete($temppath);
if ($message) {
$message = $installAddon->i18n('warning_core_not_updated') . '<br />' . $message;
$success = false;
} else {
$message = $installAddon->i18n('info_core_updated');
$success = true;
rex_delete_cache();
rex_install_webservice::deleteCache();
rex_install_packages::deleteCache();
rex::setConfig('version', $version['version']);
// ---- update package order
foreach ($updateAddons as $addon) {
if ($addon->isAvailable()) {
$addon->loadProperties();
foreach ($addon->getAvailablePlugins() as $plugin) {
$plugin->loadProperties();
}
rex_package_manager::generatePackageOrder();
}
}
}
$result = new rex_api_result($success, $message);
if ($success) {
$result->setRequiresReboot(true);
}
return $result;
}
示例4: setUp
public function setUp()
{
rex::setConfig('myCoreConfig', 'myCoreConfigValue');
rex_addon::get('tests')->setConfig('myPackageConfig', 'myPackageConfigValue');
}
示例5:
$error = rex_setup_importer::prepareEmptyDb();
if ($error != '') {
$errors[] = rex_view::error($error);
}
} else {
$errors[] = rex_view::error(rex_i18n::msg('error_undefined'));
}
if (count($errors) == 0 && $createdb !== '') {
$error = rex_setup_importer::verifyDbSchema();
if ($error != '') {
$errors[] = $error;
}
}
if (count($errors) == 0) {
rex_clang_service::generateCache();
rex::setConfig('version', rex::getVersion());
} else {
$step = 5;
}
}
if ($step > 5) {
if (!rex_setup_importer::verifyDbSchema() == '') {
$step = 5;
}
}
if ($step == 5) {
$tables_complete = rex_setup_importer::verifyDbSchema() == '' ? true : false;
$createdb = rex_post('createdb', 'int', '');
$headline = rex_view::title(rex_i18n::msg('setup_500'));
$content = '
<fieldset>