1 | <?php |
||
29 | abstract class AbstractTemplate implements Template |
||
30 | { |
||
31 | |||
32 | /** |
||
33 | * Configuration Settings. |
||
34 | * |
||
35 | * @since 1.0.0 |
||
36 | * |
||
37 | * @var ConfigInterface |
||
38 | */ |
||
39 | protected $config; |
||
40 | |||
41 | /** |
||
42 | * Name of the template. |
||
43 | * |
||
44 | * @since 1.0.0 |
||
45 | * |
||
46 | * @var string |
||
47 | */ |
||
48 | protected $templateName; |
||
49 | |||
50 | /** |
||
51 | * ViewBuilder to create template and section views. |
||
52 | * |
||
53 | * @since 1.0.0 |
||
54 | * |
||
55 | * @var ViewBuilder |
||
56 | */ |
||
57 | protected $viewBuilder; |
||
58 | |||
59 | /** |
||
60 | * Instantiate a AbstractTemplate object. |
||
61 | * |
||
62 | * @since 1.0.0 |
||
63 | * |
||
64 | * @param ConfigInterface $config Configuration settings. |
||
65 | * @param array $arguments Arguments that are passed through the constructor. |
||
66 | * Contained elements: string $template |
||
67 | * |
||
68 | * @throws RuntimeException |
||
69 | */ |
||
70 | 16 | public function __construct($config, array $arguments) |
|
76 | |||
77 | /** |
||
78 | * Get the name of the Template. |
||
79 | * |
||
80 | * @since 1.0.0 |
||
81 | * |
||
82 | * @return string Name of the template. |
||
83 | */ |
||
84 | 8 | public function getTemplateName() |
|
88 | |||
89 | /** |
||
90 | * Set the name of the Template. |
||
91 | * |
||
92 | * @since 1.0.0 |
||
93 | * |
||
94 | * @param string|null $template Optional. Name of the template. |
||
95 | * |
||
96 | * @throws FailedToInitialiseTemplate If no template name was passed. |
||
97 | * @throws FailedToInitialiseTemplate If an unknown template name was passed. |
||
98 | */ |
||
99 | 16 | protected function setTemplateName($template = null) |
|
109 | |||
110 | /** |
||
111 | * Get an array of Sections that are used by this template. |
||
112 | * |
||
113 | * @since 1.0.0 |
||
114 | * |
||
115 | * @return array Sections that are used by this template. |
||
116 | */ |
||
117 | 8 | public function getUsedSections() |
|
121 | |||
122 | /** |
||
123 | * Render the template for a given context. |
||
124 | * |
||
125 | * @since 1.0.0 |
||
126 | * |
||
127 | * @param array $context The context in which to render the template. |
||
128 | * |
||
129 | * @return string The rendered content. |
||
130 | */ |
||
131 | 8 | public function render(array $context) |
|
145 | |||
146 | /** |
||
147 | * Get the name of the View to use for rendering. |
||
148 | * |
||
149 | * @since 1.0.0 |
||
150 | * |
||
151 | * @param array $context Context in which to get the view name. |
||
152 | * |
||
153 | * @return string Name of the view. |
||
154 | */ |
||
155 | 8 | protected function getViewName(array $context) |
|
160 | } |
||
161 |