Creates template of configuration file for [[actionCompress]].
@param string $configFile output file name.
@return int CLI exit code
@throws Exception on failure.
174921
public function actionTemplate($configFile)
    {
        $jsCompressor = VarDumper::export($this->jsCompressor);
        $cssCompressor = VarDumper::export($this->cssCompressor);

        $template = <<<EOD
<?php
/**
 * Configuration file for the "yii asset" console command.
 */

// In the console environment, some path aliases may not exist. Please define these:
// \$this->app->setAlias('@webroot', __DIR__ . '/../web');
// \$this->app->setAlias('@web', '/');

return [
    // Adjust command/callback for JavaScript files compressing:
    'jsCompressor' => {$jsCompressor},
    // Adjust command/callback for CSS files compressing:
    'cssCompressor' => {$cssCompressor},
    // Whether to delete asset source after compression:
    'deleteSource' => false,
    // The list of asset bundles to compress:
    'bundles' => [
        // 'app\assets\AppAsset',
        // \yii\web\YiiAsset::class,
        // \yii\web\JqueryAsset::class,
    ],
    // Asset bundle for compression output:
    'targets' => [
        'all' => [
            '__class' => \yii\web\AssetBundle::class,
            'basePath' => '@webroot/assets',
            'baseUrl' => '@web/assets',
            'js' => 'js/all-{hash}.js',
            'css' => 'css/all-{hash}.css',
        ],
    ],
    // Asset manager configuration:
    'assetManager' => [
        //'basePath' => '@webroot/assets',
        //'baseUrl' => '@web/assets',
    ],
];
EOD;
        if (file_exists($configFile)) {
            if (!$this->confirm("File '{$configFile}' already exists. Do you wish to overwrite it?")) {
                return ExitCode::OK;
            }
        }
        if (!file_put_contents($configFile, $template, LOCK_EX)) {
            throw new Exception("Unable to write template file '{$configFile}'.");
        }

        $this->stdout("Configuration file template created at '{$configFile}'.\n\n", Console::FG_GREEN);
        return ExitCode::OK;
    }
1298368
public static function getConfigurationByConfigFile($configFile)
    {
        if (file_exists($configFile) === false) {
            $message = 'Configuration file "%s" not found or accessible.';
            $message = sprintf($message, $configFile);
            throw new \RuntimeException($message, 1415381521);
        }

        $config = Yaml::parse($configFile);
        $configuration = new Configuration($config);

        return $configuration;
    }
1021574
public function get($key, $configFile = '')
    {
        $config = $this->load((empty($configFile)) ? $this->_configFile : $configFile);

        return $this->sift($config, explode('.', $key));
    }
73170
public function load($configFileName = null)
    {
        $configs = [];

        // load all local configs (config files that are not user-facing)
        $localConfig = [];
        foreach ($this->localConfigStack as $file) {
            $config = include $file;
            $localConfig = array_merge_recursive($localConfig, $config);
        }
        if (!empty($localConfig)) {
            $configs[] = $localConfig;
        }

        // load the current project's config file (user-facing)
        if (null === $configFileName) {
            $configFileName = $this->defaultFileName;
        }
        if ($this->projectFileSystem->has($configFileName)) {
            $configs[] = Yaml::parse($this->projectFileSystem->read($configFileName));
        }

        // validate and merge all configs
        $config = $this->processor->processConfiguration(
            $this->definition,
            $configs
        );

        return new $this->configClass($config);
    }
740404
public function invokeFile(string $sourceFile, string $targetFile): ConsoleConfigInterface
    {
        $configArray          = require __DIR__ . '/../../config/default.phpunitgen.config.php';
        $configArray['files'] = [
            $sourceFile => $targetFile
        ];

        return new ConsoleConfig($configArray);
    }
906828
static void generateConfigFile(String configFilePath) throws ConfigurationException {
        String fileExtention = FilenameUtils.getExtension(configFilePath);
        ConfigProvider<Configuration> provider = getProviderByFileExtention(fileExtention);
        if (!AuditUtil.isFileExists(configFilePath)) {
            provider.generateConfig(Configuration.DEFAULT, configFilePath);
        }
    }
946865
public static function create($configFile,$baseDir="",$userDir="",$extConfigs=[])
    {
        //配置文件
        $pathInfo=pathinfo($configFile);
        $_configFile=$pathInfo["dirname"]."/".$pathInfo["filename"];
        $phpConfigFile=$_configFile.".php";
        $xmlConfigFile=$_configFile.".xml";
        $_configFile=file_exists($phpConfigFile)?$phpConfigFile:$xmlConfigFile;
        if(!file_exists($_configFile)){
            throw new \Exception("Fail to load configuration file '".$configFile."'!");
        }

        //如果缓存存在,则直接返回实例
        $configKey=$_configFile;
        if(array_key_exists($configKey, self::$m_configs)){
            return self::returnConfig(self::$m_configs[$configKey],$baseDir,$userDir,$extConfigs);
        }

        //从php配置文件读取配置:如果php配置文件存在且修改时间大于所有的xml配置文件
        if(file_exists($phpConfigFile)){
            //从php读取配置
            $config=new PhpConfiguration($phpConfigFile);

            //如果xml配置文件不存在,则直接从php配置直接返回
            if(!file_exists($xmlConfigFile)){
                self::$m_configs[$configKey]=$config;
                return self::returnConfig($config,$baseDir,$userDir,$extConfigs);
            }

            //如果xml配置文件存在,则要检查文件最后修改时间
            $phpTime=filemtime($phpConfigFile);
            $overrided=false;
            foreach ($config->getConfigValues(self::$m_configFilesKey) as $f){
                if(file_exists($f) && filemtime($f) > $phpTime){
                    $overrided=true;
                }
            }

            //php文件较新且非调试模式下
            if(!$overrided && !self::$m_debug){
                self::$m_configs[$configKey]=$config;
                return self::returnConfig($config,$baseDir,$userDir,$extConfigs);
            }
        }

        //从xml配置读取配置,并持久化到php
        if(file_exists($xmlConfigFile)){
            $config=new XmlConfiguration($xmlConfigFile);
            self::$m_configs[$configKey]=$config;
            self::dump2PhpFile($config, $phpConfigFile);
        }

        //返回实例
        if(array_key_exists($configKey, self::$m_configs)){
            return self::returnConfig(self::$m_configs[$configKey],$baseDir,$userDir,$extConfigs);
        }
        return null;
    }
164207
protected function appendTempExtension($sFile)
	{
		if($this->sTempFileExtension === '')
			throw new Exception("Programmer error: Empty temp file extension");

		$sFile .= $this->sTempFileExtension;

		$len = strlen($sFile);
		if($len > $this->nMaxFilenameLength)
			throw new Exception("Max filename length (".$this->nMaxFilenameLength.") exceeded: ".$sFile);

		return $sFile;
	}
82520
public function ClearCache($ConfigFile) {
      $FileKey = sprintf(Gdn_Configuration::CONFIG_FILE_CACHE_KEY, $ConfigFile);
      if (Gdn::Cache()->Type() == Gdn_Cache::CACHE_TYPE_MEMORY && Gdn::Cache()->ActiveEnabled()) {
         Gdn::Cache()->Remove($FileKey,array(
             Gdn_Cache::FEATURE_NOPREFIX => TRUE
         ));
      }
   }
250459
public static function read($sConfigFile)
    {
        $sConfigFile = realpath($sConfigFile);
        if(!is_readable($sConfigFile))
        {
            throw new \Jaxon\Config\Exception\File(jaxon_trans('config.errors.file.access', array('path' => $sConfigFile)));
        }
        $aConfigOptions = include($sConfigFile);
        if(!is_array($aConfigOptions))
        {
            throw new \Jaxon\Config\Exception\File(jaxon_trans('config.errors.file.content', array('path' => $sConfigFile)));
        }

        return $aConfigOptions;
    }
495555
public static void writeConfigFile(File configFile, boolean sortClasses) throws SQLException, IOException {
		writeConfigFile(configFile, new File("."), sortClasses);
	}
206585
public function readProjectConfigFile($dir, $configFile)
    {
        $result = null;
        $filename = $dir . '/' . $this->config->get('service.project_config_dir') . '/' . $configFile;
        if (file_exists($filename)) {
            $parser = new Parser();
            $result = $parser->parse(file_get_contents($filename));
        }

        return $result;
    }
527919
public function readConfig($configFile) {
        $yamlParser   = new \Symfony\Component\Yaml\Parser();
        $userConfPath = ROOT . DS . 'app' . DS . 'config' . DS . 'modules' . DS . $configFile;
        $userCustomPath = ROOT. DS . 'app'. DS.'modules'.DS.$configFile;
        $composerConfPath = ROOT . DS . 'modules' . DS . $configFile;
        $libConfPath  = ROOT_LIB . DS . 'src' . DS . 'modules' . DS . $configFile;
        if (file_exists($userConfPath)) {
            $confPath = $userConfPath;
        } elseif (file_exists($userCustomPath)) {
            $confPath = $userCustomPath;
        } elseif (file_exists($composerConfPath)) {
            $confPath = $composerConfPath;
        } elseif (file_exists($libConfPath)) {
            $confPath = $libConfPath;
        } else {
            throw new ModuleException ("Module configuration file not found!");
        }

        try {
            $conf = $yamlParser->parse(file_get_contents($confPath));
        } catch (\Symfony\Component\Yaml\Exception\ParseException $e) {
            throw new ModuleException("Unable to parse module configuration
                                            file for AutomaticHeaderFooter module: " . $e->getMessage());
        }
        return $conf;
    }
292445
protected function synchronizeConfigs(array $configFiles): void
	{
		foreach($configFiles as $variableName => $path) {
			$rowToAdd = $this->createRow($path);
			Helpers::appendToFile($this->configurationFile, $rowToAdd);
		}
	}
722956
public function makeConfig($configFile = [], $requiredConfig = [])
    {
        if (!$configFile) {
            $configFile = [];
        }

        /*
         * Config already made
         */
        if (is_object($configFile)) {
            $config = $configFile;
        }
        /*
         * Embedded config
         */
        elseif (is_array($configFile)) {
            $config = $this->makeConfigFromArray($configFile);
        }
        /*
         * Process config from file contents
         */
        else {

            if (isset($this->controller) && method_exists($this->controller, 'getConfigPath')) {
                $configFile = $this->controller->getConfigPath($configFile);
            }
            else {
                $configFile = $this->getConfigPath($configFile);
            }

            if (!File::isFile($configFile)) {
                throw new SystemException(Lang::get(
                    'system::lang.config.not_found',
                    ['file' => $configFile, 'location' => get_called_class()]
                ));
            }

            $config = Yaml::parse(File::get($configFile));

            /*
             * Extensibility
             */
            $publicFile = File::localToPublic($configFile);
            if ($results = Event::fire('system.extendConfigFile', [$publicFile, $config])) {
                foreach ($results as $result) {
                    if (!is_array($result)) {
                        continue;
                    }
                    $config = array_merge($config, $result);
                }
            }

            $config = $this->makeConfigFromArray($config);
        }

        /*
         * Validate required configuration
         */
        foreach ($requiredConfig as $property) {
            if (!property_exists($config, $property)) {
                throw new SystemException(Lang::get(
                    'system::lang.config.required',
                    ['property' => $property, 'location' => get_called_class()]
                ));
            }
        }

        return $config;
    }
862505
public static function create($errorMessageFile = '')
    {
        if (!isset(self::$instances[$errorMessageFile])) {
            self::$instances[$errorMessageFile] = new self($errorMessageFile);
        }
        return self::$instances[$errorMessageFile];
    }
65249
public function loadConfig($configFile = 'config.user.php', $configPath = 'app/config') {
        $completePath = ROOT . DS . $configPath . DS . $configFile;

        if (!file_exists($completePath)) {
            throw new ConfigException("Specified config file does not exist: " . $completePath);
        }

        include($completePath);

        if (isset($pffConfig) && is_array($pffConfig)) {
            $this->_config = array_merge($this->_config, $pffConfig);
        } else {
            throw new ConfigException("Failed to load configuration file!
                                            The file seems to be corrupted: " . $completePath);
        }
    }