AsseticResource.php 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /*
  3. * This file is part of the Symfony framework.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace Symfony\Bundle\AsseticBundle\Config;
  11. use Assetic\Factory\Resource\ResourceInterface as AsseticResourceInterface;
  12. use Symfony\Component\Config\Resource\ResourceInterface as SymfonyResourceInterface;
  13. /**
  14. * Turns an Assetic resource into a Symfony one.
  15. *
  16. * @author Kris Wallsmith <kris@symfony.com>
  17. */
  18. class AsseticResource implements SymfonyResourceInterface
  19. {
  20. private $resource;
  21. public function __construct(AsseticResourceInterface $resource)
  22. {
  23. $this->resource = $resource;
  24. }
  25. public function __toString()
  26. {
  27. return (string) $this->resource;
  28. }
  29. public function isFresh($timestamp)
  30. {
  31. return $this->resource->isFresh($timestamp);
  32. }
  33. /**
  34. * Returns the Assetic resource.
  35. *
  36. * @return AsseticResourceInterface The wrapped Assetic resource
  37. */
  38. public function getResource()
  39. {
  40. return $this->resource;
  41. }
  42. public function exists()
  43. {
  44. return true;
  45. }
  46. public function getId()
  47. {
  48. return md5('assetic'.$this->resource);
  49. }
  50. public function getModificationTime()
  51. {
  52. return -1;
  53. }
  54. public function serialize()
  55. {
  56. return serialize($this->resource);
  57. }
  58. public function unserialize($serialized)
  59. {
  60. $this->resource = unserialize($serialized);
  61. }
  62. }