Minify the given content

@param string $content
@param string $type Either js or css
@param string $filename Name of file to display in case of error
@return string minified content
770080
public function minify($content, $type, $fileName)
    {
        if ($type == 'css') {
            $minifier = new Minify\CSS();
            $minifier->add($content);
            return $minifier->minify();
        } elseif ($type == 'js') {
            $minifier = new Minify\JS();
            $minifier->add($content);
            return $minifier->minify() . ';';
        }
        return $content;
    }
218699
public function moveContent($content, $type, $page)
    {
        $contenType = $this->contentType->findOneBy(array('type' => $type, 'content' => $content));

        $contenType->detach();
        $contenType->setType($page);
        $contenType->setFirst($this->contentType->findOneBy(array('type' => $page, 'back' => null)));

        $this->manager->persist($contenType);
        $this->manager->flush();
    }
221182
public static function writeFile($filename, $content, $type = 1)
    {
        if ($type == 1) {
            is_file($filename) && self::delFile($filename); //删除文件
            self::createFile($filename);
            self::writeFile($filename, $content, 2);
            return true;
        } else {
            if (!is_writable($filename)) return false;
            $handle = fopen($filename, 'a');
            if (!$handle) return false;
            $result = fwrite($handle, $content);
            if (!$result) return false;
            fclose($handle);
            return true;
        }
    }
354686
protected function compress($content, $type, $options = array())
    {
        $commandline =array($this->javaPath);

        if (null !== $this->stackSize) {
            array_push($commandline, '-Xss'.$this->stackSize);
        }

        array_push($commandline, '-jar', $this->jarPath);

        foreach ($options as $option) {
            array_push($commandline, $option);
        }

        if (null !== $this->charset) {
            array_push($commandline, '--charset', $this->charset);
        }

        if (null !== $this->lineBreak) {
            array_push($commandline, '--line-break', $this->lineBreak);
        }

        // input and output files
        $tempDir = FilesystemUtils::getTemporaryDirectory();
        $input = tempnam($tempDir, 'assetic_yui_input');
        $output = tempnam($tempDir, 'assetic_yui_output');
        file_put_contents($input, $content);
        array_push($commandline, '-o', $output, '--type', $type, $input);

        $proc = new Process(implode(' ', $commandline));
        $code = $proc->run();
        unlink($input);

        if (0 !== $code) {
            if (file_exists($output)) {
                unlink($output);
            }

            throw FilterException::fromProcess($proc)->setInput($content);
        }

        if (!file_exists($output)) {
            throw new \RuntimeException('Error creating output file.');
        }

        $retval = file_get_contents($output);
        unlink($output);

        return $retval;
    }
1312726
public static function minify($content, array $options = [])
    {
        $compressor = new Minifier();

        if (array_key_exists('remove_important_comments', $options)) {
            $compressor->removeImportantComments($options['remove_important_comments']);
        }

        if (array_key_exists('keep_source_map_comment', $options)) {
            $compressor->keepSourceMapComment($options['keep_source_map_comment']);
        }

        return $compressor->run($content);
    }
812660
protected function _contentAttribute($content = '', $_attributes, $type)
    {
        $type   = strtolower($type);

        $perm   = $this->settings['attr']['perm'] ?? NULL;
        
        $return = '<'.$type.$this->attributes($_attributes).'>'.$this->stringOrCallback($content)."</$type>".EOL;

        $this->outputElement .= $this->_perm($perm, $return);

        return $this;
    }
1326778
public function fileContent($content)
    {
        if (is_resource($this->fileContent)) {
            fclose($this->fileContent);
        }

        $this->fileContent = $content;

        if (is_resource($content) && empty($this->fileType)) {
            $this->fileType($this->getTypeFromResource($content));
        }

        return $this;
    }
788199
public static function css($content) {
        $error = 'unknown';
        try {
            $minifier = new MatthiasMullie\Minify\CSS($content);
            return $minifier->minify();
        } catch (Exception $e) {
            $error = $e->getMessage();
        }

        $return = <<<EOD

/* Error: $error */
/* Problem detected during CSS minimisation, please review the following code */
/* ========================================================================== */


EOD;

        return $return.$content;
    }
985975
public function file($file, $type, $filename = null)
    {
        $this->type = $type;

        if(is_file($file))
        {
            $this->payload['file'] = ['name' => $type, 'contents'=> fopen($file, 'r')];
            if($filename)
                $this->payload['file']['filename'] = $filename;
        }
        else
            $this->payload[$type] = $file;

        return $this;
    }
1293085
public static function js($content) {
        try {
            $minifier = new MatthiasMullie\Minify\JS($content);
            return $minifier->minify();
        } catch (Exception $e) {
            ob_end_clean();
            $error = $e->getMessage();
        }

        $return = <<<EOD

try {console.log('Error: Minimisation of JavaScript failed!');} catch (e) {}

// Error: $error
// Problem detected during JavaScript minimisation, please review the following code
// =================================================================================


EOD;

        return $return.$content;
    }
153583
public static function compressString( $content, $type = NULL )
	{
		switch( $type )
		{
			case NULL:
				return $content;
			case 'deflate':
				return gzdeflate( $content );														//  compress Content
			case 'gzip':
				return gzencode( $content, 9 );														//  compress Content
			default:																				//  no valid Compression Method set
				throw new InvalidArgumentException( 'Compression "'.$type.'" is not supported' );
		}
	}
798893
public function addStyleDeclaration($content, $type = 'text/css')
	{
		if (!isset($this->_style[strtolower($type)]))
		{
			$this->_style[strtolower($type)] = $content;
		}
		else
		{
			$this->_style[strtolower($type)] .= chr(13) . $content;
		}

		return $this;
	}
342845
public function put($filename,$content,$type=''){
        $dir         =  dirname($filename);
        if(!is_dir($dir)){
            mkdir($dir,0777,true);
        }
        if(false === file_put_contents($filename,$content)){
            E(L('_STORAGE_WRITE_ERROR_').':'.$filename);
        }else{
            $this->contents[$filename]=$content;
            return true;
        }
    }
1323210
public function append($filename,$content,$type=''){
        if(is_file($filename)){
            $content =  $this->read($filename,$type).$content;
        }
        return $this->put($filename,$content,$type);
    }
360342
public function save($filename, $content) {
        if ($this->driver) {
            return $this->driver->save($filename, $content);
        }

        return false;
    }
127787
public function javascriptMinify($file, $type = 'file')
    {
        $file = $this->getFile($file, $type);
        $file = preg_replace(["/\/\/(.*\s+)/", "/;+\}/"], ['', '}'], $file);
        $file = $this->cleanSpaces($file);
        $file = $this->removeComments($file);

        return $file;
    }
1034857
public function addThemeCSSFile($filename, $type=null) {
		$this->addCSSURL($this->getCSSURL().$filename, $type);
	}