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\Extension\Twig; 13 14/** 15 * Filters a single asset. 16 * 17 * @author Kris Wallsmith <kris.wallsmith@gmail.com> 18 */ 19class AsseticFilterInvoker 20{ 21 private $factory; 22 private $filters; 23 private $options; 24 25 public function __construct($factory, $filter) 26 { 27 $this->factory = $factory; 28 29 if (is_array($filter) && isset($filter['filter'])) { 30 $this->filters = (array) $filter['filter']; 31 $this->options = isset($filter['options']) ? (array) $filter['options'] : array(); 32 } else { 33 $this->filters = (array) $filter; 34 $this->options = array(); 35 } 36 } 37 38 public function getFactory() 39 { 40 return $this->factory; 41 } 42 43 public function getFilters() 44 { 45 return $this->filters; 46 } 47 48 public function getOptions() 49 { 50 return $this->options; 51 } 52 53 public function invoke($input, array $options = array()) 54 { 55 $asset = $this->factory->createAsset($input, $this->filters, $options + $this->options); 56 57 return $asset->getTargetPath(); 58 } 59} 60