コード例 #1
0
 public static function checkSettingsYml($noScriptName)
 {
     $settingsYml = array();
     $settingsYmlPath = sfConfig::get('sf_app_config_dir') . '/settings.yml';
     // Read settings.yml contents from existing settings.yml, settings.yml.tmpl
     // (for a Subversion checkout), or symfony skeleton settings.yml, whichever
     // is found first
     $settingsYmlPaths = array();
     $settingsYmlPaths[] = $settingsYmlPath;
     $settingsYmlPaths[] = $settingsYmlPath . '.tmpl';
     $settingsYmlPaths[] = sfConfig::get('sf_lib_dir') . '/task/generator/skeleton/app/app/config/settings.yml';
     foreach ($settingsYmlPaths as $path) {
         if (false !== ($settingsYmlContents = file_get_contents($path))) {
             break;
         }
     }
     $settingsYmlContents = sfInstall::setNoScriptName($noScriptName, $settingsYmlContents);
     if (false === file_put_contents($settingsYmlPath, $settingsYmlContents)) {
         $settingsYml['notWritable'] = 'notWritable';
     }
     chdir(sfConfig::get('sf_root_dir'));
     // TODO By instantiating a new application configuration the cache clear
     // task may change these settings, leading to bugs in code which expects
     // them to remain constant
     $saveDebug = sfConfig::get('sf_debug');
     $saveLoggingEnabled = sfConfig::get('sf_logging_enabled');
     // TODO We do not want to cache anything during install, but currently we
     // must clear the cache after adding enabling sfInstallPlugin : (
     $cacheClear = new sfCacheClearTask(sfContext::getInstance()->getEventDispatcher(), new sfFormatter());
     $cacheClear->run();
     sfConfig::set('sf_debug', $saveDebug);
     sfConfig::set('sf_logging_enabled', $saveLoggingEnabled);
     return $settingsYml;
 }