4
* This file is part of the Assetic package, an OpenSky project.
6
* (c) 2010-2013 OpenSky Project Inc
8
* For the full copyright and license information, please view the LICENSE
9
* file that was distributed with this source code.
12
namespace Assetic\Filter;
14
use Assetic\Asset\AssetInterface;
17
* Runs assets through Packager, a JavaScript Compressor/Obfuscator.
19
* PHP Version of the Dean Edwards's Packer, ported by Nicolas Martin.
21
* @link http://joliclic.free.fr/php/javascript-packer/en/
22
* @author Maximilian Walter <github@max-walter.net>
24
class PackerFilter implements FilterInterface
26
protected $encoding = 'None';
28
protected $fastDecode = true;
30
protected $specialChars = false;
32
public function setEncoding($encoding)
34
$this->encoding = $encoding;
37
public function setFastDecode($fastDecode)
39
$this->fastDecode = (bool) $fastDecode;
42
public function setSpecialChars($specialChars)
44
$this->specialChars = (bool) $specialChars;
47
public function filterLoad(AssetInterface $asset)
51
public function filterDump(AssetInterface $asset)
53
$packer = new \JavaScriptPacker($asset->getContent(), $this->encoding, $this->fastDecode, $this->specialChars);
54
$asset->setContent($packer->pack());