當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Option::set方法代碼示例

本文整理匯總了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']);
 }
開發者ID:pramana08,項目名稱:app-cms,代碼行數:25,代碼來源:ThemeController.php

示例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']);
 }
開發者ID:tampaphp,項目名稱:app-cms,代碼行數:34,代碼來源:ThemeController.php

示例3: actionInstall

 /**
  * Install sitemap by default option.
  */
 public function actionInstall()
 {
     if (Option::set('sitemap', $this->_defaultOption)) {
         $this->redirect(['index']);
     }
 }
開發者ID:pramana08,項目名稱:app-cms,代碼行數:9,代碼來源:DefaultController.php

示例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']);
 }
開發者ID:writesdown,項目名稱:app-cms,代碼行數:26,代碼來源:ThemeController.php


注:本文中的common\models\Option::set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。