MiniAsset\Output\AssetWriter::write PHP Метод

write() публичный Метод

Writes content into a file
public write ( AssetTarget $build, string $content )
$build MiniAsset\AssetTarget The filename to write.
$content string The contents to write.
    public function write(AssetTarget $build, $content)
    {
        $ext = $build->ext();
        $path = $build->outputDir();
        if (!is_writable($path)) {
            throw new RuntimeException('Cannot write cache file. Unable to write to ' . $path);
        }
        $filename = $this->buildFileName($build);
        $success = file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $content) !== false;
        $this->finalize($build);
        return $success;
    }

Usage Example

 public function testThemeFileSaving()
 {
     $writer = new AssetWriter(['js' => false, 'css' => false], TMP, 'blue');
     $writer->write($this->target, 'theme file.');
     $contents = file_get_contents(TMP . 'blue-test.js');
     $this->assertEquals('theme file.', $contents);
     unlink(TMP . 'blue-test.js');
 }