Attempt to save the POST data for a translation file edit.

@param string     $contents
@param MutableBag $tr

@return bool|\Symfony\Component\HttpFoundation\RedirectResponse
439286
private function saveTranslationFile($contents, MutableBag $tr)
    {
        $contents = Input::cleanPostedData($contents) . "\n";

        // Clear any warning for file not found, we are creating it here
        // we'll set an error if someone still submits the form and write is not allowed
        $this->flashes()->clear();

        $file = $this->filesystem()->getFile('bolt://' . $tr->get('shortPath'));
        try {
            $file->put($contents);
        } catch (IOException $e) {
            $msg = Trans::__('general.phrase.file-not-writable', ['%s' => $tr->get('shortPath')]);
            $this->flashes()->error($msg);
            $tr['writeallowed'] = false;

            return false;
        }

        $msg = Trans::__('page.file-management.message.save-success', ['%s' => $tr->get('shortPath')]);
        $this->flashes()->info($msg);

        return $this->redirectToRoute('translation', ['domain' => $tr->get('domain'), 'tr_locale' => $tr->get('locale')]);
    }
977067
public function write($content, $mode = self::MODE_REPLACE)
    {
        $fileContent = $this->read();
        switch ($mode) {
            case self::MODE_PREPEND:
                $fileContent = $content . PHP_EOL . $fileContent;
                break;

            case self::MODE_APPEND:
                $fileContent .= PHP_EOL . $content;
                break;

            case self::MODE_REPLACE:
            default:
                $fileContent = $content;
        }

        $result = file_put_contents(
            $this->details->getRealPath(),
            $fileContent
        );

        return $result !== false;
    }
1337702
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
    {
        if ($_template->smarty->ext->_writeFile->writeFile($_template->cached->filepath, $content, $_template->smarty) === true) {
            if (function_exists('opcache_invalidate')) {
                opcache_invalidate($_template->cached->filepath);
            }
            $cached = $_template->cached;
            $cached->timestamp = $cached->exists = is_file($cached->filepath);
            if ($cached->exists) {
                $cached->timestamp = filemtime($cached->filepath);
                return true;
            }
        }
        return false;
    }
1105272
public function putContents($file, $contents)
    {
        $dir = dirname($file);
        if (! file_exists($dir)) throw new Exception("Can not put contents, not exists dirctory. -> {$dir}");
        file_put_contents($file, $contents);
    }
1111753
public function setContent(TrCollection $content)
    {
        if (count($content) > 0) {
            $this->content = $content;
        } else {
            $msg = "A Tbody object must be composed of at least 1 Tr object, none given.";
            throw new InvalidArgumentException($msg);
        }
    }
620539
public function makeViewContent($contents, $layout = null)
    {
        if ($this->suppressLayout || $this->layout == '') {
            return $contents;
        }

        // Append any undefined block content to the body block
        Block::set('undefinedBlock', $contents);
        Block::append('body', Block::get('undefinedBlock'));
        return $this->makeLayout($layout);
    }
409521
public function filePutsContent($path, $content)
    {
        if (@file_put_contents($path, $content) === false) {
            throw new \RuntimeException(sprintf("Could't puts content %s", $path));
        }

        chmod($path, 0777);
    }
1081638
public function uploadContents($name, $contents)
    {
        // raw contents not allowed
        $tmpFilesystem = new Filesystem(new Local(storage_path('tmp/')));
        $tmpFilesystem->write($name, $contents);

        $meta = Uploader::upload(storage_path('tmp/' . $name));
        // force secure url
        $meta['url'] = $meta['secure_url'];
        return $meta;
    }
617427
public function write(string $filename, string $contents): int
    {
        return (int)file_put_contents($filename, $contents);
    }
1314451
public function execInsert($redirectAction = false)
    {
        // database translations
        $this->loadTranslations('database', sprintf('private/global/locales/%s/database.ini', LANGUAGE));
        //validate and extract input
        $input = $this->processSaveInput(filter_input_array(INPUT_POST, $this->configuration['subjects'][$this->name]['CRUD']['inputFields']));
        if($input) {
            try{
                //ORM update
                $this->purgePrimaryKeyValue($input);
                if($this->insert($input)) {
                    $this->messages->save('cookies','success',sprintf($this->translations[$this->name]['CRUD']['insert-success'], $this->translations[$this->name]['singular']));
                }
            } catch(\PDOException $exception) {
                $this->messages->save('cookies', 'danger', $this->handleError($exception));
                if(!isset($redirectAction)) {
                    $redirectAction = 'insert-form';
                }
            }
        }
        //redirect
        $redirectAction = $redirectAction ? $redirectAction : 'list';
        $this->httpResponse = $this->httpResponse->withHeader('Location', $redirectAction);
    }
55827
public function write($contents) {
		$dir = new Directory($this->getDirname());
		$dir->make();
	
		file_put_contents($this->pathname, $contents);
		return $this;
	}
168794
public static function tr(
        string $content = null, 
        array $attributes = []
    ) : string
    {
        return self::tag("tr", $content, $attributes);
    }
662070
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
    {
        return $this->save(
            $_template->cached->filepath,
            $_template->source->name,
            $_template->cache_id,
            $_template->compile_id,
            $_template->properties['cache_lifetime'],
            $content
        );
    }
20858
public function setContents($contents, $name, $prefix = '')
    {
        $path = $this->rootDir . '/' . $this->getFilename($name, $prefix);

        if (!is_file($path))
        {
            throw new RuntimeException('Template not exists: ' . $path);
        }

        @file_put_contents($path, $contents);
    }
114882
public static function filePutContents($filepath, $contents, $message, $usedate = true)
    {
        $suffix = '';

        // Check date
        if ($usedate) {
            $suffix = ' on '.date('l jS \of F Y h:i:s A');
        }

        // Update contents
        $contents = !empty($contents) ? $contents."\n" : $contents;

        // Copy file contents
        file_put_contents($filepath, "/**\n * ".$message.$suffix.".\n */\n\n".$contents);
    }
1318670
public function put($path, $contents)
    {
        $path = self::validatePath($path);
        $fullPath = $this->getMediaPath($path);
        return $this->getStorageDisk()->put($fullPath, $contents);
    }
1242375
public function write($filePath, $contents, $mode = 'wb')
    {
        if (false !== ($fp = $this->create($filePath, $mode))) {
            flock($fp, LOCK_EX);

            for ($result = $written = 0, $length = strlen($contents); $written < $length; $written += $result) {
                if (($result = fwrite($fp, substr($contents, $written))) === false) {
                    break;
                }
            }

            flock($fp, LOCK_UN);
            fclose($fp);

            return is_int($result);
        }

        return false;
    }