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\Asset; 13 14use Assetic\Filter\FilterInterface; 15 16/** 17 * An asset has a mutable URL and content and can be loaded and dumped. 18 * 19 * @author Kris Wallsmith <kris.wallsmith@gmail.com> 20 */ 21interface AssetInterface 22{ 23 /** 24 * Ensures the current asset includes the supplied filter. 25 * 26 * @param FilterInterface $filter A filter 27 */ 28 public function ensureFilter(FilterInterface $filter); 29 30 /** 31 * Returns an array of filters currently applied. 32 * 33 * @return array An array of filters 34 */ 35 public function getFilters(); 36 37 /** 38 * Clears all filters from the current asset. 39 */ 40 public function clearFilters(); 41 42 /** 43 * Loads the asset into memory and applies load filters. 44 * 45 * You may provide an additional filter to apply during load. 46 * 47 * @param FilterInterface $additionalFilter An additional filter 48 */ 49 public function load(FilterInterface $additionalFilter = null); 50 51 /** 52 * Applies dump filters and returns the asset as a string. 53 * 54 * You may provide an additional filter to apply during dump. 55 * 56 * Dumping an asset should not change its state. 57 * 58 * If the current asset has not been loaded yet, it should be 59 * automatically loaded at this time. 60 * 61 * @param FilterInterface $additionalFilter An additional filter 62 * 63 * @return string The filtered content of the current asset 64 */ 65 public function dump(FilterInterface $additionalFilter = null); 66 67 /** 68 * Returns the loaded content of the current asset. 69 * 70 * @return string The content 71 */ 72 public function getContent(); 73 74 /** 75 * Sets the content of the current asset. 76 * 77 * Filters can use this method to change the content of the asset. 78 * 79 * @param string $content The asset content 80 */ 81 public function setContent($content); 82 83 /** 84 * Returns an absolute path or URL to the source asset's root directory. 85 * 86 * This value should be an absolute path to a directory in the filesystem, 87 * an absolute URL with no path, or null. 88 * 89 * For example: 90 * 91 * * '/path/to/web' 92 * * 'http://example.com' 93 * * null 94 * 95 * @return string|null The asset's root 96 */ 97 public function getSourceRoot(); 98 99 /** 100 * Returns the relative path for the source asset. 101 * 102 * This value can be combined with the asset's source root (if both are 103 * non-null) to get something compatible with file_get_contents(). 104 * 105 * For example: 106 * 107 * * 'js/main.js' 108 * * 'main.js' 109 * * null 110 * 111 * @return string|null The source asset path 112 */ 113 public function getSourcePath(); 114 115 /** 116 * Returns the asset's source directory. 117 * 118 * The source directory is the directory the asset was located in 119 * and can be used to resolve references relative to an asset. 120 * 121 * @return string|null The asset's source directory 122 */ 123 public function getSourceDirectory(); 124 125 /** 126 * Returns the URL for the current asset. 127 * 128 * @return string|null A web URL where the asset will be dumped 129 */ 130 public function getTargetPath(); 131 132 /** 133 * Sets the URL for the current asset. 134 * 135 * @param string $targetPath A web URL where the asset will be dumped 136 */ 137 public function setTargetPath($targetPath); 138 139 /** 140 * Returns the time the current asset was last modified. 141 * 142 * @return integer|null A UNIX timestamp 143 */ 144 public function getLastModified(); 145 146 /** 147 * Returns an array of variable names for this asset. 148 * 149 * @return array 150 */ 151 public function getVars(); 152 153 /** 154 * Sets the values for the asset's variables. 155 * 156 * @param array $values 157 */ 158 public function setValues(array $values); 159 160 /** 161 * Returns the current values for this asset. 162 * 163 * @return array an array of strings 164 */ 165 public function getValues(); 166} 167