Skip to content
This repository was archived by the owner on May 5, 2019. It is now read-only.

Commit e6df8ac

Browse files
committed
Update extension shim, remove unused constants
1 parent d4680f3 commit e6df8ac

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed

Diff for: compat/BaseImpl.php

+31
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Handlebars;
44

5+
use Psr\Log\LoggerInterface;
6+
57
abstract class BaseImpl implements Impl
68
{
79
/**
@@ -19,6 +21,11 @@ abstract class BaseImpl implements Impl
1921
*/
2022
protected $decorators;
2123

24+
/**
25+
* @var LoggerInterface
26+
*/
27+
protected $logger;
28+
2229
/**
2330
* @return Registry
2431
*/
@@ -43,27 +50,51 @@ public function getPartials()
4350
return $this->partials;
4451
}
4552

53+
/**
54+
* @return LoggerInterface
55+
*/
56+
public function getLogger()
57+
{
58+
return $this->logger;
59+
}
60+
4661
/**
4762
* @param Registry $helpers
63+
* @return $this
4864
*/
4965
public function setHelpers(Registry $helpers)
5066
{
5167
$this->helpers = $helpers;
68+
return $this;
5269
}
5370

5471
/**
5572
* @param Registry $partials
73+
* @return $this
5674
*/
5775
public function setPartials(Registry $partials)
5876
{
5977
$this->partials = $partials;
78+
return $this;
6079
}
6180

6281
/**
6382
* @param Registry $decorators
83+
* @return $this
6484
*/
6585
public function setDecorators(Registry $decorators)
6686
{
6787
$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;
6899
}
69100
}

Diff for: compat/Impl.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22

33
namespace Handlebars;
44

5+
use Psr\Log\LoggerInterface;
6+
use Psr\Log\LoggerAwareInterface;
7+
58
/**
69
* Note: this class is only used when the extension isn't loaded
710
*/
8-
interface Impl
11+
interface Impl extends LoggerAwareInterface
912
{
10-
const MODE_COMPILER = 'compiler';
11-
const MODE_VM = 'vm';
12-
const MODE_CVM = 'cvm';
13-
1413
public function getHelpers();
1514
public function getPartials();
1615
public function getDecorators();
16+
public function getLogger();
1717
public function setHelpers(Registry $helpers);
1818
public function setPartials(Registry $partials);
1919
public function setDecorators(Registry $decorators);
20+
public function setLogger(LoggerInterface $logger);
2021
public function render($tmpl, $context = null, array $options = null);
2122
public function renderFile($filename, $context = null, array $options = null);
2223
}

Diff for: tests/HandlebarsTest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ public function testCompileThrowsExceptionWithInvalidTemplate1()
3737

3838
public function testCompilerRenderMode()
3939
{
40-
$handlebars = new Handlebars(array(
41-
'mode' => Handlebars::MODE_COMPILER,
42-
));
40+
$handlebars = new Handlebars();
4341
$this->assertEquals('bar', $handlebars->render('{{foo}}', array(
4442
'foo' => 'bar',
4543
)));
@@ -81,7 +79,7 @@ public function testRenderSupportsStdClass()
8179

8280
public function testRenderFile()
8381
{
84-
$handlebars = new Handlebars(array('mode' => Handlebars::MODE_CVM));
82+
$handlebars = new \Handlebars\VM();
8583
$this->assertEquals('bar', $handlebars->renderFile(__DIR__ . '/fixture1.hbs', array('foo' => 'bar')));
8684
}
8785

0 commit comments

Comments
 (0)