/** * @return bool */ public static function generateConfig() { $installed = ComposerInstalledSet::get()->getInstalled(); $fileName = Yii::getAlias(ExtensionsManager::module()->extensionsStorage); $writer = new ApplicationConfigWriter(['filename' => $fileName]); $config = self::rebuldConfig($installed); $writer->addValues($config); return $writer->commit(); }
/** * @param array $data * @param string $storage * @param string $className * @throws InvalidParamException * @return bool */ public static function generateStorage($data = [], $storage, $className) { if (false === is_array($data)) { throw new InvalidParamException(Yii::t('dotplant.currencies', 'Method {method} expects array as first argument. {type} given', ['method' => __METHOD__, 'type' => gettype($data)])); } $writer = new ApplicationConfigWriter(['filename' => $storage]); $data = self::reformatData($data); $writer->addValues($data); $className::invalidateCache(); return $writer->commit(); }
/** * Writes updated extensions file */ private function writeConfig() { $fileName = Yii::getAlias($this->module->extensionsStorage); $writer = new ApplicationConfigWriter(['filename' => $fileName]); $writer->addValues($this->extensions); if (true === $writer->commit()) { $this->stdout('Extensions configuration successfully updated.' . PHP_EOL); if (true === $this->module->configurationUpdater->updateConfiguration(false)) { $this->stdout('Application configuration successfully updated.' . PHP_EOL); return true; } else { $this->stdout('Application configuration update error.' . PHP_EOL); return false; } } else { $this->stdout('There was an error while updating extensions configuration file.' . PHP_EOL); } return false; }
/** * Saves state to file * @param string $statePath Path where model state files are stored. * @return bool */ public function saveState($statePath) { $filename = Yii::getAlias($statePath . $this->stateFilename() . '.php'); $writer = new ApplicationConfigWriter(['filename' => $filename]); $writer->configuration = $this->getAttributesForStateSaving(); $result = $writer->commit(); return $result; }