本文整理匯總了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']);
}