X-Git-Url: https://git.rapsys.eu/packbundle/blobdiff_plain/fa446972465f54a247a52b87d345525a4bce3558..a8150c0f156b95dedec0350bfafc230d55ecff54:/Twig/Filter/CPackFilter.php diff --git a/Twig/Filter/CPackFilter.php b/Twig/Filter/CPackFilter.php index 806385a..ca38c3b 100644 --- a/Twig/Filter/CPackFilter.php +++ b/Twig/Filter/CPackFilter.php @@ -1,18 +1,16 @@ hasParameter('rapsys_pack_cpackfilter')) { - if ($parameters = $containerInterface->getParameter('rapsys_pack_cpackfilter')) { - foreach($parameters as $k => $v) { - if (isset($this->$k)) { - $this->$k = $v; - } - } - } - } - + //XXX: compress can be minify or pretty + public function __construct($fileName, $line, $bin = 'cpack', $compress = 'minify') { //Set fileName $this->fileName = $fileName; //Set line $this->line = $line; + //Set bin + $this->bin = $bin; + + //Set compress + $this->compress = $compress; + //Deal with compress if (!empty($this->compress)) { //Append minify parameter if ($this->compress == 'minify') { $this->bin .= ' --minify'; //Unknown compress type - #XXX: default compression is pretty + //XXX: default compression is pretty } elseif ($this->compress !== 'pretty') { //Throw an error on unknown compress - throw new \Twig_Error(sprintf('Got unexpected compress for %s: %s', $this->bin, $this->compress), $this->line, $this->fileName); + throw new Error(sprintf('Got unexpected compress for %s: %s', $this->bin, $this->compress), $this->line, $this->fileName); } } } @@ -82,7 +76,7 @@ class CPackFilter implements FilterInterface { //Read content from stderr if (($stderr = stream_get_contents($pipes[2]))) { - throw new \Twig_Error(sprintf('Got unexpected strerr for %s: %s', $this->bin, $stderr), $this->line, $this->fileName); + throw new Error(sprintf('Got unexpected strerr for %s: %s', $this->bin, $stderr), $this->line, $this->fileName); } //Close stderr @@ -90,7 +84,7 @@ class CPackFilter implements FilterInterface { //Close process if (($ret = proc_close($proc))) { - throw new \Twig_Error(sprintf('Got unexpected non zero return code %s: %d', $this->bin, $ret), $this->line, $this->fileName); + throw new Error(sprintf('Got unexpected non zero return code %s: %d', $this->bin, $ret), $this->line, $this->fileName); } }