1: <?php
2:
3: namespace Charcoal\View;
4:
5: /**
6: * Defines an object as viewable, and therefore can be rendered.
7: */
8: interface ViewableInterface
9: {
10: /**
11: * Render the viewable object.
12: *
13: * @return string
14: */
15: public function __toString();
16:
17: /**
18: * Set the viewable object's template identifier.
19: *
20: * Usually, a path to a file containing the template to be rendered at runtime.
21: *
22: * @param string $templateIdent The template ID.
23: * @return ViewableInterface Chainable
24: */
25: public function setTemplateIdent($templateIdent);
26:
27: /**
28: * Retrieve the viewable object's template identifier.
29: *
30: * @return string
31: */
32: public function templateIdent();
33:
34: /**
35: * Set the renderable view.
36: *
37: * @param ViewInterface|array $view The view instance to use to render.
38: * @return ViewableInterface Chainable
39: */
40: public function setView(ViewInterface $view);
41:
42: /**
43: * Retrieve the renderable view.
44: *
45: * @return ViewInterface The object's View instance.
46: */
47: public function view();
48:
49: /**
50: * Render the template by the given identifier.
51: *
52: * Usually, a path to a file containing the template to be rendered at runtime.
53: *
54: * @param string $templateIdent The template to load, parse, and render.
55: * If NULL, will use the object's previously set template identifier.
56: * @return string The rendered template.
57: */
58: public function render($templateIdent = null);
59:
60: /**
61: * Render the given template from string.
62: *
63: * @param string $templateString The template to render from string.
64: * @return string The rendered template.
65: */
66: public function renderTemplate($templateString);
67: }
68: