1<?php 2 3/* 4 * This file is part of the Assetic package, an OpenSky project. 5 * 6 * (c) 2010-2014 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 12namespace Assetic\Filter; 13 14use Assetic\Asset\AssetInterface; 15 16/** 17 * Filters assets through CssMin. 18 * 19 * @link http://code.google.com/p/cssmin 20 * @author Kris Wallsmith <kris.wallsmith@gmail.com> 21 */ 22class CssMinFilter implements FilterInterface 23{ 24 private $filters; 25 private $plugins; 26 27 public function __construct() 28 { 29 $this->filters = array(); 30 $this->plugins = array(); 31 } 32 33 public function setFilters(array $filters) 34 { 35 $this->filters = $filters; 36 } 37 38 public function setFilter($name, $value) 39 { 40 $this->filters[$name] = $value; 41 } 42 43 public function setPlugins(array $plugins) 44 { 45 $this->plugins = $plugins; 46 } 47 48 public function setPlugin($name, $value) 49 { 50 $this->plugins[$name] = $value; 51 } 52 53 public function filterLoad(AssetInterface $asset) 54 { 55 } 56 57 public function filterDump(AssetInterface $asset) 58 { 59 $filters = $this->filters; 60 $plugins = $this->plugins; 61 62 if (isset($filters['ImportImports']) && true === $filters['ImportImports']) { 63 if ($dir = $asset->getSourceDirectory()) { 64 $filters['ImportImports'] = array('BasePath' => $dir); 65 } else { 66 unset($filters['ImportImports']); 67 } 68 } 69 70 $asset->setContent(\CssMin::minify($asset->getContent(), $filters, $plugins)); 71 } 72} 73