33
44use PHPForm \Renderers \TwigRenderer ;
55use PHPForm \TemplatePacks \DefaultTemplatePack ;
6+ use PHPForm \Messages ;
67
78class Config extends Singleton
89{
@@ -14,6 +15,11 @@ class Config extends Singleton
1415 DefaultTemplatePack::class,
1516 );
1617
18+ /**
19+ * @var string Renderer class used to render html content.
20+ */
21+ protected $ messages_class = Messages::class;
22+
1723 /**
1824 * @var string Renderer class used to render html content.
1925 */
@@ -25,17 +31,33 @@ class Config extends Singleton
2531 private $ renderer ;
2632
2733 /**
28- * Return renderer class instantiated
34+ * Set template pack on top level.
2935 *
30- * @return PHPForm\Renderers\Renderer
36+ * @param string Class name of TemplatePack.
3137 */
32- public function getRenderer ( )
38+ public function setTemplatePack ( string $ template_pack )
3339 {
34- if (is_null ($ this ->renderer )) {
35- $ this ->renderer = new $ this ->renderer_class ($ this ->getTemplatesDirs ());
36- }
40+ $ this ->template_packs = array_unshift ($ this ->template_packs , $ template_pack );
41+ }
3742
38- return $ this ->renderer ;
43+ /**
44+ * Set messages class.
45+ *
46+ * @param string Class name of Renderer.
47+ */
48+ public function setMessages (string $ messages_class )
49+ {
50+ $ this ->messages_class = $ messages_class ;
51+ }
52+
53+ /**
54+ * Get messages class.
55+ *
56+ * @param Messages Messages class.
57+ */
58+ public function getMessages ()
59+ {
60+ return $ this ->messages_class ;
3961 }
4062
4163 /**
@@ -49,13 +71,17 @@ public function setRenderer(string $renderer_class)
4971 }
5072
5173 /**
52- * Set template pack on top level.
74+ * Return renderer class instantiated
5375 *
54- * @param string Class name of TemplatePack.
76+ * @return PHPForm\Renderers\Renderer
5577 */
56- public function setTemplatePack ( string $ template_pack )
78+ public function getRenderer ( )
5779 {
58- $ this ->template_packs = array_unshift ($ this ->template_packs , $ template_pack );
80+ if (is_null ($ this ->renderer )) {
81+ $ this ->renderer = new $ this ->renderer_class ($ this ->getTemplatesDirs ());
82+ }
83+
84+ return $ this ->renderer ;
5985 }
6086
6187 /**
0 commit comments