String.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) 2009 Fabien Potencier
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. @trigger_error('The Twig_Loader_String class is deprecated since version 1.18.1 and will be removed in 2.0. Use Twig_Loader_Array instead or Twig_Environment::createTemplate().', E_USER_DEPRECATED);
  11. /**
  12. * Loads a template from a string.
  13. *
  14. * This loader should NEVER be used. It only exists for Twig internal purposes.
  15. *
  16. * When using this loader with a cache mechanism, you should know that a new cache
  17. * key is generated each time a template content "changes" (the cache key being the
  18. * source code of the template). If you don't want to see your cache grows out of
  19. * control, you need to take care of clearing the old cache file by yourself.
  20. *
  21. * @deprecated since 1.18.1 (to be removed in 2.0)
  22. *
  23. * @internal
  24. *
  25. * @author Fabien Potencier <fabien@symfony.com>
  26. */
  27. class Twig_Loader_String implements Twig_LoaderInterface, Twig_ExistsLoaderInterface
  28. {
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function getSource($name)
  33. {
  34. return $name;
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function exists($name)
  40. {
  41. return true;
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function getCacheKey($name)
  47. {
  48. return $name;
  49. }
  50. /**
  51. * {@inheritdoc}
  52. */
  53. public function isFresh($name, $time)
  54. {
  55. return true;
  56. }
  57. }