当前位置: 首页>>代码示例>>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;未经允许,请勿转载。