Save the config to the configured file action

@return null
5992
public function saveConfigAction() {
        $cfgr = Mage::getModel('turpentine/varnish_admin')->getConfigurator();
        if (is_null($cfgr)) {
            $this->_getSession()->addError(
                $this->__('Failed to load configurator') );
        } else {
            Mage::dispatchEvent('turpentine_varnish_save_config',
                array('cfgr' => $cfgr));
            $result = $cfgr->save($cfgr->generate(
                Mage::helper('turpentine')->shouldStripVclWhitespace('save') ));
            if ($result[0]) {
                $this->_getSession()
                    ->addSuccess(Mage::helper('turpentine')
                        ->__('The VCL file has been saved.'));
            } else {
                $this->_getSession()
                    ->addError(Mage::helper('turpentine')
                        ->__('Failed to save the VCL file: '.$result[1]['message']));
            }
        }
        $this->_redirect('*/cache');
    }
718103
protected function __save()
    {
        $this->parseDate();
        foreach($this->records as $record)
        {
            FileUtil::writeFile($this->getFileName(), $this->getLogString($record) . PHP_EOL, FILE_APPEND);
        }
    }
1303452
protected function save()
    {
        $filename = Path::create([$this->outputPath(), $this->outputFile()]);

        return (bool) \file_put_contents($filename->toString(), $this->stub);
    }
1050172
public function settingsSave()
    {
        $config = app('itemconfig');
        $save   = $config->save($this->request, app('admin_field_factory')->getEditFields());

        if (is_string($save)) {
            return response()->json(array(
                'success' => false,
                'errors'  => $save,
            ));
        } else {
            //override the config options so that we can get the latest
            app('admin_config_factory')->updateConfigOptions();

            return response()->json(array(
                'success' => true,
                'data'    => $config->getDataModel(),
                'actions' => app('admin_action_factory')->getActionsOptions(),
            ));
        }
    }
1058382
def save(self):
        
        with open(self._filename, "w") as f:
            self.config.write(f)
998565
public function saveConfig($selfedit = "false") {
		$this->selfedit = $selfedit;
		
		if ($selfedit == "true") {
			$this->moufManager = MoufManager::getMoufManager();
		} else {
			$this->moufManager = MoufManager::getMoufManagerHiddenInstance();
		}
		
		$this->configManager = $this->moufManager->getConfigManager();
		$this->constantsList = $this->configManager->getMergedConstants();
		
		$constants = array();
		foreach ($this->constantsList as $key=>$def) {
			if ($def['defined'] == true && $def['type'] == 'bool') {
				$constants[$key] = (get($key)=="true")?true:false;
			} else {
				$constants[$key] = get($key);
			}
		}
		$this->configManager->setDefinedConstants($constants);
		
		header("Location: .?selfedit=".$selfedit);
	}
871454
public function editAction() {
		$configForm = $this->getForm();
        /* @var $request \Zend\Http\Request */
        $request = $this->getRequest();
		
        if ($request->isPost()) {
			$data = $request->getPost();
			$configForm->setData($data);
			if ($configForm->isValid()) {
				$configData = $configForm->getData();
				$flatConfig = $this->flattenConfig($configData['config'], $this->getConfigPrefix());
				$this->saveConfig($flatConfig);
				
				$this->flashMessenger()->addSuccessMessage($this->getTranslator()->translate('Configuration successfully saved'));
				return $this->_redirectToIndex();
			}
        } else {
			$configForm->setData($this->getConfig());
		}
		
		$view = new ViewModel(array('title' => $this->getEditTitle(), 'configForm' => $configForm));
		$view->setTemplate('xelax-site-config/site-config/edit.phtml');
		return $view;
	}
1042409
public function save()
    {
        $module = isset(Yii::$app->controller) ? Yii::$app->controller->module : null;
        if ($this->operation === self::OP_CREATE) {
            $dir = dirname($this->path);
            if (!is_dir($dir)) {
                if ($module instanceof \yii\gii\Module) {
                    $mask = @umask(0);
                    $result = @mkdir($dir, $module->newDirMode, true);
                    @umask($mask);
                } else {
                    $result = @mkdir($dir, 0777, true);
                }
                if (!$result) {
                    return "Unable to create the directory '$dir'.";
                }
            }
        }
        if (@file_put_contents($this->path, $this->content) === false) {
            return "Unable to write the file '{$this->path}'.";
        }

        if ($module instanceof \yii\gii\Module) {
            $mask = @umask(0);
            @chmod($this->path, $module->newFileMode);
            @umask($mask);
        }

        return true;
    }
156485
public function save()
	{
		$result=true;
		foreach($this->files as $file)
		{
			if($this->confirmed($file))
				$result=$file->save() && $result;
		}
		return $result;
	}
429067
function instance_config_save($data, $nolongerused = false) {
        global $DB;

        $config = clone($data);
        // Move embedded files into a proper filearea and adjust HTML links to match
        $config->text = file_save_draft_area_files($data->text['itemid'], $this->context->id, 'block_html', 'content', 0, array('subdirs'=>true), $data->text['text']);
        $config->format = $data->text['format'];

        parent::instance_config_save($config, $nolongerused);
    }
1059505
public function save() {
        $configdata = $this->get('configdata');
        if (!array_key_exists('defaultvalue_editor', $configdata)) {
            $this->field->save();
            return;
        }

        if (!$this->get('id')) {
            $this->field->save();
        }

        // Store files.
        $textoptions = $this->value_editor_options();
        $tempvalue = (object) ['defaultvalue_editor' => $configdata['defaultvalue_editor']];
        $tempvalue = file_postupdate_standard_editor($tempvalue, 'defaultvalue', $textoptions, $textoptions['context'],
            'customfield_textarea', 'defaultvalue', $this->get('id'));

        $configdata['defaultvalue'] = $tempvalue->defaultvalue;
        $configdata['defaultvalueformat'] = $tempvalue->defaultvalueformat;
        unset($configdata['defaultvalue_editor']);
        $this->field->set('configdata', json_encode($configdata));
        $this->field->save();
    }
1353450
public function save()
    {
        $data = $this->toData();

        if (file_exists($this->_configuration_file) && !is_writable($this->_configuration_file)) {
            chmod($this->_configuration_file, 0644);
        }

        $file = new \SplFileObject($this->_configuration_file, 'w');
        $file->fwrite("<?php\n");
        $file->fwrite("class AnSiteConfig {\n\n");

        $print_array = function($array) use (&$print_array) {

            if (is_array($array)) {

                $values = array();
                $hash   = !is_numeric(key($array));

                foreach ($array as $key => $value) {

                    if ( !is_numeric($key) ) {
                        $key = "'".addslashes($key)."'";
                    }

                    if ( !is_numeric($value) ) {
                        $value = "'".addslashes($value)."'";
                    }

                    $values[] = $hash ? "$key=>$value" : $value;
                }

                return 'array('.implode(',', $values).')';
            }
        };

        $write = function($data) use($file, $print_array) {

            foreach($data as $key => $value) {

                if (is_array($value)) {
                    $value = $print_array($value);
                } elseif ( !is_numeric($value) ) {
                    $value = "'".addslashes($value)."'";
                }

                $file->fwrite("   var \$$key = $value;\n");
            }
        };

        $write_group = function($keys, $comment = null) use (&$data, $file, $write) {

            $values = array();

            foreach ($keys as $key) {

                if (isset($data[$key])) {
                    $values[$key] = $data[$key];
                    unset($data[$key]);
                }
            }

            if (!empty($values)) {

                if (!empty($comment)) {
                    $file->fwrite("   /*$comment*/\n");
                }

                $write($values);
                $file->fwrite("\n");
            }
        };

        $write_group(array('sitename'), 'Site Settings');
        $write_group(array('dbtype', 'host', 'user', 'password', 'db', 'dbprefix'), 'Database Settings');
        $write_group(array('sef_rewrite', 'live_site', 'secret', 'error_reporting', 'tmp_path', 'log_path', 'force_ssl'), 'Server Settings');
        $write_group(array('mailer', 'mailfrom', 'fromname', 'sendmail', 'smtpauth', 'smtpuser', 'smtppass', 'smtphost'), 'Mail Settings');
        $write_group(array('debug'), 'Debug Settings');
        $write_group(array_keys($data), 'Other configurations');
        $file->fwrite("}");

        $this->_clearCache();
    }
682268
def save(self, filename=None):
        """"""
        if self.__fname is None and filename is None:
            raise ValueError('Config loaded from string, no filename specified')
        conf = self.__config
        cpa = dict_to_cp(conf)
        with open(self.__fname if filename is None else filename, 'w') as f:
            cpa.write(f)
1252907
def save(self):
        """"""
        try:
            os.makedirs(os.path.dirname(self._configfile))
        except:
            pass

        with open(self._configfile, 'w') as f:
            self._config.write(f)
395825
public function saveConfiguration($settings)
    {
        if (file_exists($this->path) && !is_writable($this->path)) {
            throw new Exception('The file "' . $this->path . '" isn\'t writable!');
        }
        
        $content = json_encode($settings);
        
        return file_put_contents($this->path, $content);
    }
144031
def save(self, filename=None, verbose=False):
        ''' 
        '''
        if filename is None:
            if (not self.has_section(self.application_name) or
                    not self.has_option(self.application_name, 'config_file')):
                if not self.has_section(self.application_name):
                    self.add_section(self.application_name)
                if not self.application_name in self.config_description:
                    self.config_description[self.application_name] = {}

                appdir = AppDirs(self.application_name,
                        self.application_author,
                        version=self.application_version)
                value = os.path.join(appdir.user_data_dir, '{0}.conf'.format(
                    self.application_name.lower()))
                if not self.has_option(self.application_name, 'config_file'):
                    self.set(self.application_name, 'config_file', value)
                if not ('config_file' in
                        self.config_description[self.application_name]):
                    self.config_description[self.application_name]\
                            ['config_file'] = ('The config file to '
                                'overwrite on change of the config values. '
                                '[$HOME/.{0}/{0}.conf]'.format(
                                    self.application_name), str, value)

            filename = self.get(self.application_name, 'config_file')

        if not os.path.exists(os.path.dirname(filename)):
            os.makedirs(os.path.dirname(filename))

        hidden = None
        if self.has_section('hidden'):
            hidden = self.items('hidden')
            self.remove_section('hidden')

        cfp = open(filename, 'w')
        self._write_config(cfp, verbose)
        cfp.close()

        if hidden is not None:
            for key, value in hidden:
                self.set('hidden', key, value)
133055
public function actionSave()
    {
        if(Yii::$app->request->isAjax)
        {
            $p = Yii::$app->request->post();
            // after find there are old values (see modules/OneFile::afterFind())
            $model = OneFile::findOne($p['file_id']);
            // so, change them for new defs (see modules/OneFile::beforeSave())
            $model->vars = json_decode($p['defs']);
            $model->save(false, ['defs']);
            
            echo $p['file_id'];
        }
    }