[7575] | 1 | <?php |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | * This file is part of the Assetic package, an OpenSky project. |
---|
| 5 | * |
---|
| 6 | * (c) 2010-2012 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\Asset; |
---|
| 13 | |
---|
| 14 | use 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 | */ |
---|
| 21 | interface 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 URL for the current asset. |
---|
| 117 | * |
---|
| 118 | * @return string|null A web URL where the asset will be dumped |
---|
| 119 | */ |
---|
| 120 | public function getTargetPath(); |
---|
| 121 | |
---|
| 122 | /** |
---|
| 123 | * Sets the URL for the current asset. |
---|
| 124 | * |
---|
| 125 | * @param string $targetPath A web URL where the asset will be dumped |
---|
| 126 | */ |
---|
| 127 | public function setTargetPath($targetPath); |
---|
| 128 | |
---|
| 129 | /** |
---|
| 130 | * Returns the time the current asset was last modified. |
---|
| 131 | * |
---|
| 132 | * @return integer|null A UNIX timestamp |
---|
| 133 | */ |
---|
| 134 | public function getLastModified(); |
---|
| 135 | |
---|
| 136 | /** |
---|
| 137 | * Returns an array of variable names for this asset. |
---|
| 138 | * |
---|
| 139 | * @return array |
---|
| 140 | */ |
---|
| 141 | public function getVars(); |
---|
| 142 | |
---|
| 143 | /** |
---|
| 144 | * Sets the values for the asset's variables. |
---|
| 145 | * |
---|
| 146 | * @param array $values |
---|
| 147 | */ |
---|
| 148 | public function setValues(array $values); |
---|
| 149 | |
---|
| 150 | /** |
---|
| 151 | * Returns the current values for this asset. |
---|
| 152 | * |
---|
| 153 | * @return array an array of strings |
---|
| 154 | */ |
---|
| 155 | public function getValues(); |
---|
| 156 | } |
---|