AssetInterface.php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /*
  3. * This file is part of the Assetic package, an OpenSky project.
  4. *
  5. * (c) 2010-2011 OpenSky Project Inc
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Assetic\Asset;
  11. use Assetic\Filter\FilterInterface;
  12. /**
  13. * An asset has a mutable URL and content and can be loaded and dumped.
  14. *
  15. * @author Kris Wallsmith <kris.wallsmith@gmail.com>
  16. */
  17. interface AssetInterface
  18. {
  19. /**
  20. * Ensures the current asset includes the supplied filter.
  21. *
  22. * @param FilterInterface $filter A filter
  23. */
  24. function ensureFilter(FilterInterface $filter);
  25. /**
  26. * Returns an array of filters currently applied.
  27. *
  28. * @return array An array of filters
  29. */
  30. function getFilters();
  31. /**
  32. * Clears all filters from the current asset.
  33. */
  34. function clearFilters();
  35. /**
  36. * Loads the asset into memory and applies load filters.
  37. *
  38. * You may provide an additional filter to apply during load.
  39. *
  40. * @param FilterInterface $additionalFilter An additional filter
  41. */
  42. function load(FilterInterface $additionalFilter = null);
  43. /**
  44. * Applies dump filters and returns the asset as a string.
  45. *
  46. * You may provide an additional filter to apply during dump.
  47. *
  48. * Dumping an asset should not change its state.
  49. *
  50. * If the current asset has not been loaded yet, it should be
  51. * automatically loaded at this time.
  52. *
  53. * @param FilterInterface $additionalFilter An additional filter
  54. *
  55. * @return string The filtered content of the current asset
  56. */
  57. function dump(FilterInterface $additionalFilter = null);
  58. /**
  59. * Returns the loaded content of the current asset.
  60. *
  61. * @return string The content
  62. */
  63. function getContent();
  64. /**
  65. * Sets the content of the current asset.
  66. *
  67. * Filters can use this method to change the content of the asset.
  68. *
  69. * @param string $content The asset content
  70. */
  71. function setContent($content);
  72. /**
  73. * Returns an absolute path or URL to the source asset's root directory.
  74. *
  75. * This value should be an absolute path to a directory in the filesystem,
  76. * an absolute URL with no path, or null.
  77. *
  78. * For example:
  79. *
  80. * * '/path/to/web'
  81. * * 'http://example.com'
  82. * * null
  83. *
  84. * @return string|null The asset's root
  85. */
  86. function getSourceRoot();
  87. /**
  88. * Returns the relative path for the source asset.
  89. *
  90. * This value can be combined with the asset's source root (if both are
  91. * non-null) to get something compatible with file_get_contents().
  92. *
  93. * For example:
  94. *
  95. * * 'js/main.js'
  96. * * 'main.js'
  97. * * null
  98. *
  99. * @return string|null The source asset path
  100. */
  101. function getSourcePath();
  102. /**
  103. * Returns the URL for the current asset.
  104. *
  105. * @return string|null A web URL where the asset will be dumped
  106. */
  107. function getTargetPath();
  108. /**
  109. * Sets the URL for the current asset.
  110. *
  111. * @param string $targetPath A web URL where the asset will be dumped
  112. */
  113. function setTargetPath($targetPath);
  114. /**
  115. * Returns the time the current asset was last modified.
  116. *
  117. * @return integer|null A UNIX timestamp
  118. */
  119. function getLastModified();
  120. }