]> Raphaƫl G. Git Repositories - packbundle/blobdiff - Twig/Filter/JPackFilter.php
Rename pack_package into path_package
[packbundle] / Twig / Filter / JPackFilter.php
index 43aeb86738456f61d053c48f1412f8d62ab2fa93..ca4555d71affc37e70dc88acfdf5a87135fcad57 100644 (file)
@@ -1,18 +1,16 @@
 <?php
 
 <?php
 
-// src/Rapsys/PackBundle/Twig/Filter/JPackFilter.php
 namespace Rapsys\PackBundle\Twig\Filter;
 
 use Rapsys\PackBundle\Twig\Filter\FilterInterface;
 namespace Rapsys\PackBundle\Twig\Filter;
 
 use Rapsys\PackBundle\Twig\Filter\FilterInterface;
-use Symfony\Component\DependencyInjection\ContainerInterface;
+use Twig\Error\Error;
 
 class JPackFilter implements FilterInterface {
        //Default bin
 
 class JPackFilter implements FilterInterface {
        //Default bin
-       private $bin = 'jpack';
+       private $bin;
 
        //Default compress type
 
        //Default compress type
-       //XXX: can be clean, shrink, obfuscate or best
-       private $compress = 'best';
+       private $compress;
 
        //Twig template filename
        private $fileName;
 
        //Twig template filename
        private $fileName;
@@ -20,24 +18,21 @@ class JPackFilter implements FilterInterface {
        //Twig template line
        private $line;
 
        //Twig template line
        private $line;
 
-       public function __construct(ContainerInterface $containerInterface, $fileName, $line) {
-               //Load configuration
-               if ($containerInterface->hasParameter('rapsys_pack.jpackfilter')) {
-                       if ($parameters = $containerInterface->getParameter('rapsys_pack.jpackfilter')) {
-                               foreach($parameters as $k => $v) {
-                                       if (isset($this->$k)) {
-                                               $this->$k = $v;
-                                       }
-                               }
-                       }
-               }
-
+       //Configure the object
+       //XXX: can be clean, shrink, obfuscate or best
+       public function __construct($fileName, $line, $bin = 'jpack', $compress = 'best') {
                //Set fileName
                $this->fileName = $fileName;
 
                //Set line
                $this->line = $line;
 
                //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 clean parameter
                //Deal with compress
                if (!empty($this->compress)) {
                        //Append clean parameter
@@ -50,10 +45,10 @@ class JPackFilter implements FilterInterface {
                        } elseif ($this->compress == 'obfuscate') {
                                $this->bin .= ' --obfuscate';
                        //Unknown compress type
                        } elseif ($this->compress == 'obfuscate') {
                                $this->bin .= ' --obfuscate';
                        //Unknown compress type
-                       #XXX: default compression is best
+                       //XXX: default compression is best
                        } elseif ($this->compress !== 'best') {
                                //Throw an error on unknown compress
                        } elseif ($this->compress !== 'best') {
                                //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);
                        }
                }
        }
                        }
                }
        }
@@ -87,7 +82,7 @@ class JPackFilter implements FilterInterface {
 
                        //Read content from stderr
                        if (($stderr = stream_get_contents($pipes[2]))) {
 
                        //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
                        }
 
                        //Close stderr
@@ -95,7 +90,7 @@ class JPackFilter implements FilterInterface {
 
                        //Close process
                        if (($ret = proc_close($proc))) {
 
                        //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);
                        }
                }
 
                        }
                }