本文整理匯總了PHP中humhub\models\Setting::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP Setting::find方法的具體用法?PHP Setting::find怎麽用?PHP Setting::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類humhub\models\Setting
的用法示例。
在下文中一共展示了Setting::find方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: rewrite
/**
* Rewrites DynamicConfiguration based on Database Stored Settings
*/
public static function rewrite()
{
// Get Current Configuration
$config = self::load();
// Add Application Name to Configuration
$config['name'] = Setting::Get('name');
// Add Default language
$defaultLanguage = Setting::Get('defaultLanguage');
if ($defaultLanguage !== null && $defaultLanguage != "") {
$config['language'] = Setting::Get('defaultLanguage');
} else {
$config['language'] = Yii::$app->language;
}
$timeZone = Setting::Get('timeZone');
if ($timeZone != "") {
$config['timeZone'] = $timeZone;
$config['components']['formatter']['defaultTimeZone'] = $timeZone;
$config['components']['formatterApp']['defaultTimeZone'] = $timeZone;
$config['components']['formatterApp']['timeZone'] = $timeZone;
}
// Add Caching
$cacheClass = Setting::Get('type', 'cache');
if (in_array($cacheClass, ['yii\\caching\\DummyCache', 'yii\\caching\\ApcCache', 'yii\\caching\\FileCache'])) {
$config['components']['cache'] = ['class' => $cacheClass, 'keyPrefix' => Yii::$app->id];
// Prefix APC Cache Keys
//if ($cacheClass == 'yii\caching\ApcCache') {
// $config['components']['cache'] = [
// 'keyPrefix' => Yii::$app->id
// ];
//}
}
// Add User settings
$config['components']['user'] = array();
if (Setting::Get('defaultUserIdleTimeoutSec', 'authentication_internal')) {
$config['components']['user']['authTimeout'] = Setting::Get('defaultUserIdleTimeoutSec', 'authentication_internal');
}
// Install Mail Component
$mail = [];
$mail['transport'] = array();
if (Setting::Get('transportType', 'mailing') == 'smtp') {
$mail['transport']['class'] = 'Swift_SmtpTransport';
if (Setting::Get('hostname', 'mailing')) {
$mail['transport']['host'] = Setting::Get('hostname', 'mailing');
}
if (Setting::Get('username', 'mailing')) {
$mail['transport']['username'] = Setting::Get('username', 'mailing');
}
if (Setting::Get('password', 'mailing')) {
$mail['transport']['password'] = Setting::Get('password', 'mailing');
}
if (Setting::Get('encryption', 'mailing')) {
$mail['transport']['encryption'] = Setting::Get('encryption', 'mailing');
}
if (Setting::Get('port', 'mailing')) {
$mail['transport']['port'] = Setting::Get('port', 'mailing');
}
/*
if (Setting::Get('allowSelfSignedCerts', 'mailing')) {
$mail['transport']['ssl']['allow_self_signed'] = true;
$mail['transport']['ssl']['verify_peer'] = false;
}
*/
} elseif (Setting::Get('transportType', 'mailing') == 'php') {
$mail['transport']['class'] = 'Swift_MailTransport';
} else {
$mail['useFileTransport'] = true;
}
$config['components']['mailer'] = $mail;
$config = ArrayHelper::merge($config, Theme::getThemeConfig(Setting::Get('theme')));
$config['params']['config_created_at'] = time();
foreach (Setting::find()->all() as $setting) {
self::setSettingValue($config['params'], $setting);
}
self::save($config);
}