This repository was archived by the owner on May 5, 2019. It is now read-only.
File tree 3 files changed +39
-9
lines changed
3 files changed +39
-9
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace Handlebars ;
4
4
5
+ use Psr \Log \LoggerInterface ;
6
+
5
7
abstract class BaseImpl implements Impl
6
8
{
7
9
/**
@@ -19,6 +21,11 @@ abstract class BaseImpl implements Impl
19
21
*/
20
22
protected $ decorators ;
21
23
24
+ /**
25
+ * @var LoggerInterface
26
+ */
27
+ protected $ logger ;
28
+
22
29
/**
23
30
* @return Registry
24
31
*/
@@ -43,27 +50,51 @@ public function getPartials()
43
50
return $ this ->partials ;
44
51
}
45
52
53
+ /**
54
+ * @return LoggerInterface
55
+ */
56
+ public function getLogger ()
57
+ {
58
+ return $ this ->logger ;
59
+ }
60
+
46
61
/**
47
62
* @param Registry $helpers
63
+ * @return $this
48
64
*/
49
65
public function setHelpers (Registry $ helpers )
50
66
{
51
67
$ this ->helpers = $ helpers ;
68
+ return $ this ;
52
69
}
53
70
54
71
/**
55
72
* @param Registry $partials
73
+ * @return $this
56
74
*/
57
75
public function setPartials (Registry $ partials )
58
76
{
59
77
$ this ->partials = $ partials ;
78
+ return $ this ;
60
79
}
61
80
62
81
/**
63
82
* @param Registry $decorators
83
+ * @return $this
64
84
*/
65
85
public function setDecorators (Registry $ decorators )
66
86
{
67
87
$ this ->decorators = $ decorators ;
88
+ return $ this ;
89
+ }
90
+
91
+ /**
92
+ * @param LoggerInterface $logger
93
+ * @return $this
94
+ */
95
+ public function setLogger (LoggerInterface $ logger )
96
+ {
97
+ $ this ->logger = $ logger ;
98
+ return $ this ;
68
99
}
69
100
}
Original file line number Diff line number Diff line change 2
2
3
3
namespace Handlebars ;
4
4
5
+ use Psr \Log \LoggerInterface ;
6
+ use Psr \Log \LoggerAwareInterface ;
7
+
5
8
/**
6
9
* Note: this class is only used when the extension isn't loaded
7
10
*/
8
- interface Impl
11
+ interface Impl extends LoggerAwareInterface
9
12
{
10
- const MODE_COMPILER = 'compiler ' ;
11
- const MODE_VM = 'vm ' ;
12
- const MODE_CVM = 'cvm ' ;
13
-
14
13
public function getHelpers ();
15
14
public function getPartials ();
16
15
public function getDecorators ();
16
+ public function getLogger ();
17
17
public function setHelpers (Registry $ helpers );
18
18
public function setPartials (Registry $ partials );
19
19
public function setDecorators (Registry $ decorators );
20
+ public function setLogger (LoggerInterface $ logger );
20
21
public function render ($ tmpl , $ context = null , array $ options = null );
21
22
public function renderFile ($ filename , $ context = null , array $ options = null );
22
23
}
Original file line number Diff line number Diff line change @@ -37,9 +37,7 @@ public function testCompileThrowsExceptionWithInvalidTemplate1()
37
37
38
38
public function testCompilerRenderMode ()
39
39
{
40
- $ handlebars = new Handlebars (array (
41
- 'mode ' => Handlebars::MODE_COMPILER ,
42
- ));
40
+ $ handlebars = new Handlebars ();
43
41
$ this ->assertEquals ('bar ' , $ handlebars ->render ('{{foo}} ' , array (
44
42
'foo ' => 'bar ' ,
45
43
)));
@@ -81,7 +79,7 @@ public function testRenderSupportsStdClass()
81
79
82
80
public function testRenderFile ()
83
81
{
84
- $ handlebars = new Handlebars ( array ( ' mode ' => Handlebars:: MODE_CVM ) );
82
+ $ handlebars = new \ Handlebars \ VM ( );
85
83
$ this ->assertEquals ('bar ' , $ handlebars ->renderFile (__DIR__ . '/fixture1.hbs ' , array ('foo ' => 'bar ' )));
86
84
}
87
85
You can’t perform that action at this time.
0 commit comments