EngineInterface.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 relies 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 use the logical template name to look for
  24. * the template.
  25. *
  26. * @author Fabien Potencier <fabien@symfony.com>
  27. *
  28. * @api
  29. */
  30. interface EngineInterface
  31. {
  32. /**
  33. * Renders a template.
  34. *
  35. * @param mixed $name A template name or a TemplateReferenceInterface instance
  36. * @param array $parameters An array of parameters to pass to the template
  37. *
  38. * @return string The evaluated template as a string
  39. *
  40. * @throws \RuntimeException if the template cannot be rendered
  41. *
  42. * @api
  43. */
  44. public function render($name, array $parameters = array());
  45. /**
  46. * Returns true if the template exists.
  47. *
  48. * @param mixed $name A template name or a TemplateReferenceInterface instance
  49. *
  50. * @return Boolean true if the template exists, false otherwise
  51. *
  52. * @api
  53. */
  54. public function exists($name);
  55. /**
  56. * Returns true if this class is able to render the given template.
  57. *
  58. * @param mixed $name A template name or a TemplateReferenceInterface instance
  59. *
  60. * @return Boolean true if this class supports the given template, false otherwise
  61. *
  62. * @api
  63. */
  64. public function supports($name);
  65. }