本文整理汇总了PHP中common\models\Option::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Option::set方法的具体用法?PHP Option::set怎么用?PHP Option::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common\models\Option
的用法示例。
在下文中一共展示了Option::set方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionInstall
/**
* Install selected theme.
*
* @param string $theme
*
* @return \yii\web\Response
*/
public function actionInstall($theme)
{
$fileConfig = $this->_themeDir . $theme . '/config/main.php';
if (is_file($fileConfig)) {
$config = (require_once $fileConfig);
if (!is_array($config)) {
Yii::$app->getSession()->setFlash('danger', Yii::t('writesdown', "File config must return an array."));
} else {
if (Option::set('theme', $theme)) {
Yii::$app->getSession()->setFlash('success', Yii::t('writesdown', "Theme successfully installed."));
}
}
} else {
Yii::$app->getSession()->setFlash('danger', Yii::t('writesdown', "Theme not successfully installed. Error: invalid config file"));
}
// Redirect to index when the theme successfully installed
return $this->redirect(['index']);
}
示例2: actionInstall
/**
* Install selected theme and run install and uninstall action based on config.
*
* @param string $theme
*
* @return \yii\web\Response
*/
public function actionInstall($theme)
{
if (is_file($fileConfigInstalled = $this->_themeDir . Option::get('theme') . '/config/main.php')) {
$configOld = (require $fileConfigInstalled);
if (isset($configOld['uninstall'])) {
try {
Yii::createObject($configOld['uninstall']);
} catch (Exception $e) {
}
}
}
if (is_file($fileConfigInstall = $this->_themeDir . $theme . '/config/main.php')) {
$configNew = (require $fileConfigInstall);
if (isset($configNew['install'])) {
try {
Yii::createObject($configNew['install']);
} catch (Exception $e) {
}
}
}
if (Option::set('theme', $theme)) {
Yii::$app->getSession()->setFlash('success', Yii::t('writesdown', "Theme successfully installed."));
} else {
Yii::$app->getSession()->setFlash('danger', Yii::t('writesdown', "File config must return an array."));
}
return $this->redirect(['index']);
}
示例3: actionInstall
/**
* Install sitemap by default option.
*/
public function actionInstall()
{
if (Option::set('sitemap', $this->_defaultOption)) {
$this->redirect(['index']);
}
}
示例4: actionInstall
/**
* Install selected theme and run install and uninstall action based on config.
*
* @param string $theme
*
* @return \yii\web\Response
*/
public function actionInstall($theme)
{
foreach (ArrayHelper::getValue($this->getConfig(Option::get('theme')), 'uninstall', []) as $type) {
try {
Yii::createObject($type);
} catch (Exception $e) {
}
}
foreach (ArrayHelper::getValue($this->getConfig($theme), 'install', []) as $type) {
try {
Yii::createObject($type);
} catch (Exception $e) {
}
}
if (Option::set('theme', $theme)) {
Yii::$app->getSession()->setFlash('success', Yii::t('writesdown', "Theme successfully installed."));
}
return $this->redirect(['index']);
}