EngineInterface.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  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 Symfony\Component\Templating;
  11. /**
  12. * EngineInterface is the interface each engine must implement.
  13. *
  14. * All methods rely on a template name. A template name is a
  15. * "logical" name for the template, and as such it does not refer to
  16. * a path on the filesystem (in fact, the template can be stored
  17. * anywhere, like in a database).
  18. *
  19. * The methods should accept any name. If the name is not an instance of
  20. * TemplateReferenceInterface, a TemplateNameParserInterface should be used to
  21. * convert the name to a TemplateReferenceInterface instance.
  22. *
  23. * Each template loader uses the logical template name to look for
  24. * the template.
  25. *
  26. * @author Fabien Potencier <fabien@symfony.com>
  27. */
  28. interface EngineInterface
  29. {
  30. /**
  31. * Renders a template.
  32. *
  33. * @param string|TemplateReferenceInterface $name A template name or a TemplateReferenceInterface instance
  34. * @param array $parameters An array of parameters to pass to the template
  35. *
  36. * @return string The evaluated template as a string
  37. *
  38. * @throws \RuntimeException if the template cannot be rendered
  39. */
  40. public function render($name, array $parameters = array());
  41. /**
  42. * Returns true if the template exists.
  43. *
  44. * @param string|TemplateReferenceInterface $name A template name or a TemplateReferenceInterface instance
  45. *
  46. * @return bool true if the template exists, false otherwise
  47. *
  48. * @throws \RuntimeException if the engine cannot handle the template name
  49. */
  50. public function exists($name);
  51. /**
  52. * Returns true if this class is able to render the given template.
  53. *
  54. * @param string|TemplateReferenceInterface $name A template name or a TemplateReferenceInterface instance
  55. *
  56. * @return bool true if this class supports the given template, false otherwise
  57. */
  58. public function supports($name);
  59. }