/** * Initialization of cache component. * @throws InvalidConfigException if cacheComponent is incorrect. */ protected function initCacheComponent() { if ($this->cacheComponent === null || is_array($this->cacheComponent)) { $this->cacheComponent = Yii::createObject(array_merge(['class' => FileCache::className(), 'cachePath' => rtrim($this->compiledPath, '\\/') . '/cache', 'fileMode' => $this->fileMode, 'dirMode' => $this->mkDirMode], $this->cacheComponent ?: [])); } elseif (is_string($this->cacheComponent)) { $this->cacheComponent = Yii::$app->get($this->cacheComponent); } if ($this->cacheComponent !== false && !$this->cacheComponent instanceof Cache) { throw new InvalidConfigException('Incorrect value of ' . __CLASS__ . '::$cacheComponent param. Calculated value of this param must be an instance of ' . Cache::className() . '.'); } }
/** * Rewrites the configuration file */ public static function rewriteConfiguration() { // Get Current Configuration $config = Configuration::get(); // Add Application Name to Configuration $config['name'] = Yii::$app->config->get(Enum::APP_NAME); // Add Caching $cacheClass = Yii::$app->config->get(Enum::CACHE_CLASS); if (!$cacheClass) { $cacheClass = FileCache::className(); } $config['components']['cache'] = ['class' => $cacheClass]; // Add Auth Clients $config['components']['authClientCollection']['class'] = 'yii\\authclient\\Collection'; Configuration::set($config); }
?> </div> <div class="form-group"> <?php echo $form->field($model, 'appFrontendTheme')->dropDownList($themes, ['class' => 'form-control', 'options' => [Yii::$app->config->get(Enum::APP_FRONTEND_THEME, 'readable') => ['selected ' => TRUE]]]); ?> </div> <hr/> <h4>Cache Setting</h4> <div class="form-group"> <?php echo $form->field($model, 'cacheClass')->dropDownList([FileCache::className() => 'File Cache', DbCache::className() => 'Db Cache'], ['class' => 'form-control', 'options' => [Yii::$app->config->get(Enum::CACHE_CLASS, FileCache::className()) => ['selected ' => TRUE]]]); ?> </div> <hr/> <h4>Introduction Tour</h4> <div class="form-group"> <div class="checkbox"> <?php echo $form->field($model, 'appTour')->checkbox(); ?> </div> </div>
$collectorsConfigPath = CANIS_APP_CONFIG_PATH . DIRECTORY_SEPARATOR . 'modules.php'; if (file_exists($collectorsConfigPath)) { $base['components']['collectors'] = (include $collectorsConfigPath); } else { $base['components']['collectors'] = (include 'collectors.php'); } } if (!isset($base['components']['cache'])) { if (isset($base['components']['redis'])) { $base['components']['cache'] = ['class' => RedisCache::className()]; } else { $base['components']['cache'] = ['class' => DummyCache::className()]; } } if (!isset($base['components']['fileCache'])) { $base['components']['fileCache'] = ['class' => FileCache::className()]; } if (!isset($base['components']['gk'])) { $base['components']['gk'] = ['class' => Gatekeeper::className(), 'authority' => ['type' => 'Individual']]; } if (class_exists('cascade\\models\\User')) { $base['components']['user'] = ['class' => 'canis\\web\\User', 'enableAutoLogin' => false, 'identityClass' => 'cascade\\server\\models\\User', 'loginUrl' => ['/user/login']]; } if (!isset($base['components']['fileStorage'])) { $base['components']['fileStorage'] = ['class' => FileStorage::className()]; } if (!isset($base['components']['view'])) { $base['components']['view'] = ['class' => View::className()]; } if (!isset($base['components']['response'])) { $base['components']['response'] = ['class' => Response::className()];