Jarves\Filesystem\Filesystem::write PHP Method

write() public method

public write ( string $path, string $content = '' ) : boolean
$path string
$content string
return boolean
    public function write($path, $content = '')
    {
        $fs = $this->getAdapter($path);
        return $fs->write($this->normalizePath($path), $content);
    }

Usage Example

Example #1
0
 /**
  * @param array $files
  *
  * @return AssetInfo
  */
 public function compressFiles(array $files)
 {
     $md5String = '';
     foreach ($files as $file) {
         $path = $this->getAssetPath($file);
         $md5String .= '.' . filemtime($path);
     }
     $fileUpToDate = false;
     $md5Line = '/* ' . md5($md5String) . " */\n";
     $oFile = 'cache/compressed-css/' . md5($md5String) . '.css';
     $handle = @fopen($this->getJarves()->getRootDir() . '/../web/' . $oFile, 'r');
     if ($handle) {
         $line = fgets($handle);
         fclose($handle);
         if ($line == $md5Line) {
             $fileUpToDate = true;
         }
     }
     if (!$fileUpToDate) {
         $content = $this->utils->compressCss($files, 'cache/compressed-css/');
         $content = $md5Line . $content;
         $this->webFilesystem->write($oFile, $content);
     }
     $assetInfo = new AssetInfo();
     $assetInfo->setPath($oFile);
     return $assetInfo;
 }
All Usage Examples Of Jarves\Filesystem\Filesystem::write