Skip to content
Snippets Groups Projects
Commit 76d084e0 authored by Jaime Pérez's avatar Jaime Pérez
Browse files

Define SimpleSAML\XHTML\Template::$twig as a property (previously only set in...

Define SimpleSAML\XHTML\Template::$twig as a property (previously only set in the constructor) and make sure we use proper type checking when using it.
parent f4d82061
Branches
Tags
No related merge requests found
...@@ -51,6 +51,13 @@ class SimpleSAML_XHTML_Template ...@@ -51,6 +51,13 @@ class SimpleSAML_XHTML_Template
*/ */
private $template = 'default.php'; private $template = 'default.php';
/**
* The twig environment.
*
* @var false|Twig_Environment
*/
private $twig;
/** /**
* The template name. * The template name.
* *
...@@ -155,7 +162,7 @@ class SimpleSAML_XHTML_Template ...@@ -155,7 +162,7 @@ class SimpleSAML_XHTML_Template
$loader = $this->setupTwigTemplatepaths(); $loader = $this->setupTwigTemplatepaths();
// abort if twig template does not exist // abort if twig template does not exist
if (!$loader->exists($this->twig_template)) { if (!$loader->exists($this->twig_template)) {
return null; return false;
} }
$twig = new \Twig_Environment($loader, $twig = new \Twig_Environment($loader,
...@@ -317,7 +324,7 @@ class SimpleSAML_XHTML_Template ...@@ -317,7 +324,7 @@ class SimpleSAML_XHTML_Template
*/ */
public function show() public function show()
{ {
if ($this->twig) { if ($this->twig !== false) {
$this->twigDefaultContext(); $this->twigDefaultContext();
echo $this->twig->render($this->twig_template, $this->data); echo $this->twig->render($this->twig_template, $this->data);
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment