Save .env file.

@param $results
@return bool
494996
protected function saveFile($results)
    {
        $file = fopen($this->envFilePath('.env'), 'w+');
        foreach ($results as $variable => $value)
        {
            fwrite($file, $variable . '=' . $value . PHP_EOL);
        }

        return fclose($file);
    }
354760
protected function processExportData($columns, $results, $options)
    {
        /*
         * Validate
         */
        if (!$results) {
            throw new ApplicationException(Lang::get('backend::lang.import_export.empty_error'));
        }

        /*
         * Parse options
         */
        $defaultOptions = [
            'firstRowTitles' => true,
            'useOutput' => false,
            'fileName' => 'export.csv',
            'delimiter' => null,
            'enclosure' => null,
            'escape' => null
        ];

        $options = array_merge($defaultOptions, $options);
        $columns = $this->exportExtendColumns($columns);

        /*
         * Prepare CSV
         */
        $csv = CsvWriter::createFromFileObject(new SplTempFileObject);
        
        $csv->setOutputBOM(CsvWriter::BOM_UTF8);

        if ($options['delimiter'] !== null) {
            $csv->setDelimiter($options['delimiter']);
        }

        if ($options['enclosure'] !== null) {
            $csv->setEnclosure($options['enclosure']);
        }

        if ($options['escape'] !== null) {
            $csv->setEscape($options['escape']);
        }

        /*
         * Add headers
         */
        if ($options['firstRowTitles']) {
            $headers = $this->getColumnHeaders($columns);
            $csv->insertOne($headers);
        }

        /*
         * Add records
         */
        foreach ($results as $result) {
            $data = $this->matchDataToColumns($result, $columns);
            $csv->insertOne($data);
        }

        /*
         * Output
         */
        if ($options['useOutput']) {
            $csv->output($options['fileName']);
        }

        /*
         * Save for download
         */
        $csvName = uniqid('oc');
        $csvPath = temp_path().'/'.$csvName;
        $output = $csv->__toString();

        File::put($csvPath, $output);

        return $csvName;
    }
856355
public function saveEnvironment($environment) {
        $environment = (object) $environment;

        $environment_config = (array) $environment;
        unset($environment_config['app']);
        $this->config['apps'][$environment->app]['environments'][$environment->name] = $environment_config;
    }
2939
public function saveCallbackResult($result)
    {
        // get cache key
        $cacheKey = $this->getCacheKey();

        // cache the result
        try {
            $cache = $this->cache($this->requestBag->getApiConfig()->get('Cache'));

            return $cache->save($cacheKey, $result, $this->requestBag->getMethodData()['cache']['ttl']);
        } catch (\Exception $e) {
            throw new RestException('Unable to save the result into cache. ' . $e->getMessage());
        }
    }
589494
public function setResults($results)
    {
        // hydrate model
        foreach ($results as $entry) {
            /** @var EntityDataModel $model */
            $model = $this->getModel();
            $model->setEntityManager($this->getEntityManager());

            // check for json
            if (array_key_exists('[json]', $entry)) {
                $entry = json_decode($entry['[json]']);
            }

            $model = $this->populate($entry, $model);

            $this->collection[] = $model;
        }

        $this->setCount(count($this->collection));

        return $this;
    }
1310287
public function environment(...$environments)
    {
        $env = \env('APP_ENV', 'production');

        if (\func_num_args() > 0) {
            $patterns = \is_array($environments[0]) ? $environments[0] : $environments;

            foreach ($patterns as $pattern) {
                if (Str::is($pattern, $env)) {
                    return true;
                }
            }

            return false;
        }

        return $env;
    }
140325
protected function checkResult(array $results, array $params)
    {
        $exceptions = new Exception\SaveException();

        for ($i = 0; $i < count($results); $i++) {

            // If the param was an (s)object, set it’s Id field
            if (is_object($params[$i])
                && (!isset($params[$i]->Id) || null === $params[$i]->Id)
                && $results[$i] instanceof Result\SaveResult) {
                $params[$i]->Id = $results[$i]->getId();
            }

            if (!$results[$i]->isSuccess()) {
                $results[$i]->setParam($params[$i]);
                $exceptions->add($results[$i]);
            }
        }

        if ($exceptions->count() > 0) {
            throw $exceptions;
        }

        return $results;
    }
511930
public function store($env, array $data)
    {
        $this->files->put($this->path($env), '<?php return '.var_export($data, true).';'.PHP_EOL);
    }
856611
public function writeEnvFile($string)
    {
        file_put_contents($this->laravel->environmentPath().'/'.$this->laravel->environmentFile(), $string);
    }
900343
public function setResults($results = null, bool $stopPropagation = false) {
        $this->result = $results;
        if ($stopPropagation) {
            $this->stopPropagation();
        }
    }
177047
public function save($editor)
	{
		$this->load();

		// Check whether editor is already loaded
		if (is_null($this->editor))
		{
			return;
		}

		$return = '';
		$results[] = $this->editor->onSave($editor);

		foreach ($results as $result)
		{
			if (trim($result))
			{
				$return .= $result;
			}
		}

		return $return;
	}
909250
private function process(Statement $results)
    {
        return $this->manager
            ->getResultProcessor()
            ->processRecords(
                $this->entity,
                $this->with,
                $this->fetchResults(
                    $results,
                    $this->entity->getPrimaryKey()
                ),
                $this->readOnly
            );
    }
810935
public function write(&$result)
    {
        $container = $this->accessor->getPropertyValue($result, $this->definition->container());
        if (empty($container)) {
            $conditions = [];
            foreach ($this->definition->localKeys() as $local => $foreign) {
                $conditions[$foreign][] = $this->accessor->getPropertyValue($result, $local);
            }

            $this->cleanup($this->definition->mediator(), [], $conditions);
            return $result;
        }

        foreach ($container as $entity) {
            $this->storage->write($entity, $this->definition->entity())->execute();
        }

        $mediators = [];

        foreach ($container as $entity) {
            $mediator = [];

            foreach ($this->definition->localKeys() as $local => $foreign) {
                $mediator[$foreign] = $this->accessor->getPropertyValue($result, $local);
            }

            foreach ($this->definition->foreignKeys() as $foreign => $local) {
                $mediator[$foreign] = $this->accessor->getPropertyValue($entity, $local);
            }

            $this->storage->write($mediator, $this->definition->mediator())
                ->execute();

            $mediators[] = $mediator;
        }

        $this->accessor->setPropertyValue($result, $this->definition->container(), $container);

        $conditions = [];
        foreach ($this->definition->localKeys() as $foreign) {
            foreach ($mediators as $mediator) {
                $conditions[$foreign][] = $this->accessor->getPropertyValue($mediator, $foreign);
            }
        }

        $this->cleanup($this->definition->mediator(), $mediators, $conditions);

        return $result;
    }
1323627
private function mergeAfterSave($result)
    {
        $this->applyOperations($this->operationSet, $this->serverData);
        $this->mergeFromServer($result);
        $this->operationSet = array();
        $this->rebuildEstimatedData();
    }
130212
public function save($output, array $options = []) {
		$this->_image->save($output, $options);
		$this->_image = null;
		return true;
	}
1223902
private function getFormattedResults(&$results) {
    return implode('', array(
        $this->getReportInfo($results),
        $this->getPaginationInfo($results),
        $this->getProfileInformation($results),
        $this->getQueryParameters($results),
        $this->getColumnHeaders($results),
        $this->getTotalsForAllResults($results),
        $this->getRows($results)
    ));
    
  }
146324
private function saveInstallationMap($result = array())
	{
		//
		// Temporarily remove original checksums
		//

		if (isset($this->installationMap['__CHECKSUMS__'])) {
			$original_checksums = $this->installationMap['__CHECKSUMS__'];

			unset($this->installationMap['__CHECKSUMS__']);

		} else {
			$original_checksums = array();
		}

		if ($result && isset($result['updates'])) {
			foreach ($result['updates'] as $opus_path => $checksum) {
				$original_checksums[$opus_path] = $checksum;
			}
		}

		$this->installationMap['__CHECKSUMS__'] = $original_checksums;

		//
		// Write our map
		//

		if (file_exists($this->mapFile)) {
			if (!is_writable($this->mapFile) || is_dir($this->mapFile)) {
				throw new \Exception(sprintf(
					'Cannot write to map file at %s', $this->mapFile
				));
			}

		}

		if (!file_put_contents($this->mapFile, json_encode($this->installationMap))) {
			throw new \Exception(sprintf(
				'Error while saving map file at %s', $this->mapFile
			));
		}
	}