本文整理汇总了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);
}