~ubuntu-branches/debian/stretch/assetic/stretch

« back to all changes in this revision

Viewing changes to src/Assetic/Filter/PackerFilter.php

  • Committer: Package Import Robot
  • Author(s): David Prévot
  • Date: 2014-04-21 12:48:05 UTC
  • Revision ID: package-import@ubuntu.com-20140421124805-y9ri97838g33fo9z
Tags: upstream-1.1.2
Import upstream version 1.1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/*
 
4
 * This file is part of the Assetic package, an OpenSky project.
 
5
 *
 
6
 * (c) 2010-2013 OpenSky Project Inc
 
7
 *
 
8
 * For the full copyright and license information, please view the LICENSE
 
9
 * file that was distributed with this source code.
 
10
 */
 
11
 
 
12
namespace Assetic\Filter;
 
13
 
 
14
use Assetic\Asset\AssetInterface;
 
15
 
 
16
/**
 
17
 * Runs assets through Packager, a JavaScript Compressor/Obfuscator.
 
18
 *
 
19
 * PHP Version of the Dean Edwards's Packer, ported by Nicolas Martin.
 
20
 *
 
21
 * @link http://joliclic.free.fr/php/javascript-packer/en/
 
22
 * @author Maximilian Walter <github@max-walter.net>
 
23
 */
 
24
class PackerFilter implements FilterInterface
 
25
{
 
26
    protected $encoding = 'None';
 
27
 
 
28
    protected $fastDecode = true;
 
29
 
 
30
    protected $specialChars = false;
 
31
 
 
32
    public function setEncoding($encoding)
 
33
    {
 
34
        $this->encoding = $encoding;
 
35
    }
 
36
 
 
37
    public function setFastDecode($fastDecode)
 
38
    {
 
39
        $this->fastDecode = (bool) $fastDecode;
 
40
    }
 
41
 
 
42
    public function setSpecialChars($specialChars)
 
43
    {
 
44
        $this->specialChars = (bool) $specialChars;
 
45
    }
 
46
 
 
47
    public function filterLoad(AssetInterface $asset)
 
48
    {
 
49
    }
 
50
 
 
51
    public function filterDump(AssetInterface $asset)
 
52
    {
 
53
        $packer = new \JavaScriptPacker($asset->getContent(), $this->encoding, $this->fastDecode, $this->specialChars);
 
54
        $asset->setContent($packer->pack());
 
55
    }
 
56
}