Skip to content

Commit a675f21

Browse files
committed
Change: Twig::createTwig() creates only one Twig_Environment instance now
1 parent 21754c5 commit a675f21

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

libraries/Twig.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,20 @@ public function __construct($params = [])
3535
$this->config = array_merge($this->config, $params);
3636
}
3737

38+
public function resetTwig()
39+
{
40+
$this->twig = null;
41+
$this->createTwig();
42+
}
43+
3844
public function createTwig()
3945
{
46+
// $this->twig is singleton
47+
if ($this->twig !== null)
48+
{
49+
return;
50+
}
51+
4052
if (ENVIRONMENT === 'production')
4153
{
4254
$debug = FALSE;

tests/libraries/TwigHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function setUp()
1919
'site_url' => '{{ site_url(\'"><s>abc</s><a name="test\') }}',
2020
]);
2121
$CI->twig->setLoader($loader);
22-
$CI->twig->createTwig();
22+
$CI->twig->resetTwig();
2323

2424
$this->obj = $CI->twig;
2525
$this->twig = $CI->twig->getTwig();

0 commit comments

Comments
 (0)