Skip to content

Commit

Permalink
use twig namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared King committed Apr 30, 2019
1 parent 5579684 commit c0dca34
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Fixed
- No longer send a response body when one has not been supplied.
- Stop using deprecated Twig classes and switch to namespaces (Twig 2.7+)

## 1.0 - 2017-12-02
### Changed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
"smarty/smarty": ">=v3.1.19",
"mockery/mockery": "~1.0",
"mustache/mustache": "2.7.0",
"twig/twig": "~1.0"
"twig/twig": "~2.7"
}
}
12 changes: 6 additions & 6 deletions src/ViewEngine/Twig.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

use Infuse\ViewEngine;
use Infuse\View;
use Twig_Environment;
use Twig_Loader_Filesystem;
use Twig\Environment;
use Twig\Loader\FilesystemLoader;

class Twig extends ViewEngine
{
Expand All @@ -25,7 +25,7 @@ class Twig extends ViewEngine
private $viewsDir = 'views';

/**
* @var Twig_Environment
* @var Environment
*/
private $twig;

Expand Down Expand Up @@ -79,13 +79,13 @@ public function renderView(View $view)
/**
* Gets (and creates) a new Twig instance.
*
* @return Twig_Environment
* @return Environment
*/
public function twig()
{
if (!$this->twig) {
$loader = new Twig_Loader_Filesystem($this->viewsDir);
$this->twig = new Twig_Environment($loader, $this->twigConfig);
$loader = new FilesystemLoader($this->viewsDir);
$this->twig = new Environment($loader, $this->twigConfig);
}

return $this->twig;
Expand Down
3 changes: 2 additions & 1 deletion tests/ViewEngine/TwigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Infuse\ViewEngine\Twig;
use Infuse\View;
use Mockery\Adapter\Phpunit\MockeryTestCase;
use Twig\Environment;

class TwigViewEngineTest extends MockeryTestCase
{
Expand Down Expand Up @@ -49,7 +50,7 @@ public function testGlobalParameters()
public function testTwig()
{
$engine = new Twig(__DIR__.'/views');
$this->assertInstanceOf('Twig_Environment', $engine->twig());
$this->assertInstanceOf(Environment::class, $engine->twig());
}

public function testRenderView()
Expand Down

0 comments on commit c0dca34

Please sign in to comment.