1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
-
- /*
- * This file is part of the Assetic package, an OpenSky project.
- *
- * (c) 2010-2012 OpenSky Project Inc
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
- namespace Assetic\Filter;
-
- use Assetic\Asset\AssetInterface;
-
- /**
- * Filters assets through CssMin.
- *
- * @author Kris Wallsmith <kris.wallsmith@gmail.com>
- */
- class CssMinFilter implements FilterInterface
- {
- private $filters;
- private $plugins;
-
- public function __construct()
- {
- $this->filters = array();
- $this->plugins = array();
- }
-
- public function setFilters(array $filters)
- {
- $this->filters = $filters;
- }
-
- public function setFilter($name, $value)
- {
- $this->filters[$name] = $value;
- }
-
- public function setPlugins(array $plugins)
- {
- $this->plugins = $plugins;
- }
-
- public function setPlugin($name, $value)
- {
- $this->plugins[$name] = $value;
- }
-
- public function filterLoad(AssetInterface $asset)
- {
- }
-
- public function filterDump(AssetInterface $asset)
- {
- $filters = $this->filters;
- $plugins = $this->plugins;
-
- if (isset($filters['ImportImports']) && true === $filters['ImportImports']) {
- $root = $asset->getSourceRoot();
- $path = $asset->getSourcePath();
- if ($root && $path) {
- $filters['ImportImports'] = array('BasePath' => dirname($root.'/'.$path));
- } else {
- unset($filters['ImportImports']);
- }
- }
-
- $asset->setContent(\CssMin::minify($asset->getContent(), $filters, $plugins));
- }
- }
|