Write the finished command file to disk.

@param  string  $file
@param  string  $stub
@return void
975380
protected function writeCommand($file, $stub)
	{
		if ( ! file_exists($file))
		{
			$this->files->put($file, $this->formatStub($stub));

			$this->info('Command created successfully.');
		}
		else
		{
			$this->error('Command already exists!');
		}
	}
938760
function write($file,array $data=NULL) {
		if (!$this->dir || $this->lazy)
			return count($this->data[$file]=$data);
		$fw=\Base::instance();
		switch ($this->format) {
			case self::FORMAT_JSON:
				$out=json_encode($data,JSON_PRETTY_PRINT);
				break;
			case self::FORMAT_Serialized:
				$out=$fw->serialize($data);
				break;
		}
		return $fw->write($this->dir.'/'.$file,$out);
	}
330470
public function write($file, $data)
    {
        $file = '/data/' . $file;

        /**
         * @todo validate that $file is a string
         * @todo validate that $data is a string
         */

        $data = json_decode(json_encode($data), true);

        $data_content = isset($data['content']) ? $data['content'] : '';

        unset($data['content']);

        $data = '---' . PHP_EOL . trim($this->yaml->dump($data, 5)) . PHP_EOL . '---' . PHP_EOL . $data_content;

        $this->source_filesystem->createDir(dirname($file));

        $this->source_filesystem->put($file, $data);
    }
645425
protected function store($stub)
    {
        $output = $this->getOutputPath();
        if ($this->files->exists($output)) {
            return false;
        }
        $this->files->put($output, $stub);
        return true;
    }
979326
protected function replaceScope(string &$stub, string $scope)
    {

        if (strlen($scope) > 0)
            $stub = str_replace("'public'", "'$scope'", $stub);

        return $this;
    }
998796
protected function initConfig($file) {
		if(file_exists($this->dir.'/'.$file)) {
			if(!$this->confirm('Do you want to override "'.$file.'"?'))
				return;
		}

		$config = file_get_contents(__DIR__.'/stubs/'.$file.'.stub');
		$key = \Asgard\Common\Tools::randStr(10);
		$config = str_replace('_KEY_', $key, $config);

		if(\Asgard\File\FileSystem::write($this->dir.'/'.$file, $config))
			$this->info('Configuration file "'.$file.'" created with success.');
		else
			$this->error('Configuration file "'.$file.'" creation failed.');
	}
412648
protected function replaceStubFileData(&$stub)
    {
        $stub = str_replace(
            ['DummyVendor', 'DummyName', 'DummyLowerVendor', 'DummyLowerName'],
            [$this->getVendorInput(), $this->getNameInput(), strtolower($this->getVendorInput()), strtolower($this->getNameInput())],
            $stub
        );

        return $this;
    }
387177
public function writeToPluginFile($file, $data)
    {
        $this->writeToFile(
            $this->config['plugins'] . Utils::unleadslashit($file),
            $data
        );
    }
778588
public function saveToDisk($file = null)
    {
        if ($file !== null && is_string($file)) {
            if (file_exists($file) && !(is_file($file) && is_writable($file))) {
                throw new OdfException('Permission denied : can\'t create ' . $file);
            }
            $this->_save();
            copy($this->tmpfile, $file);
        } else {
            $this->_save();
        }
    }
191877
public function saveFile($data, $file)
    {
        $openfile = @fopen($file, "wb") or die("saveFile: Error opening file '{$file}'.");
        @fwrite($openfile, $data) or die("saveFile: Error writing data into file '{$file}'.");
        @fclose($openfile);
    }
1130038
public static function write(string $file, $content, int $mode = 0666): void
	{
		NetteFileSystem::write($file, $content, $mode);
	}
1303452
protected function save()
    {
        $filename = Path::create([$this->outputPath(), $this->outputFile()]);

        return (bool) \file_put_contents($filename->toString(), $this->stub);
    }
50099
protected function writeCacheFile($file, $content)
  {
    parent::writeCacheFile($file, $content);

    // Compile cached-file into bytecode-cache
    if (function_exists('apc_compile_file') === true) {
      apc_compile_file($file);
    }
  }
1017980
private function readFileContent(string $file): void
    {
        $autodetect = ini_get('auto_detect_line_endings');
        ini_set('auto_detect_line_endings', '1');
        $lines = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
        ini_set('auto_detect_line_endings', $autodetect);

        $this->lines = array_merge($this->lines, $lines);
    }
522897
protected function writeComposerFile(Package $package, $directory, $plain)
	{
		$stub = $this->getComposerStub($plain);

		$stub = $this->formatPackageStub($package, $stub);

		$this->files->put($directory.'/composer.json', $stub);
	}
118657
protected function writeFragment($fragment) {
		$fileHandle = fopen($this->outputFile, $this->writeMode);

		fwrite($fileHandle, $fragment);
		fclose($fileHandle);

		// appends to the file initially created with $writeMode = "w"
		$this->writeMode = 'a';
	}
924357
private function callCommandFile($type, $name = null, $stub = null, $options = [])
    {
        $this->call('generate:file', array_merge($options, [
            'name'    => ($name ? $name : $this->argument('resource')),
            '--type'  => $type,
            '--force' => $this->optionForce(),
            '--plain' => $this->optionPlain(),
            '--stub'  => ($stub ? $stub : $this->optionStub()),
        ]));
    }