Skip to content
Snippets Groups Projects
Unverified Commit d0e09690 authored by Jaime Pérez Crespo's avatar Jaime Pérez Crespo
Browse files

Add a method to get the twig object used in a template.

This allows template users to use their own twig extensions if they want, while also allowing us to remove the "twigInit" hook. Hooks come at a price, and it doesn't make much sense to use them in this case, as they would only be useful if a module wants to add a twig extension even if the code instantiating SimpleSAML_XHTML_Template does not belong to that module. This could lead to unexpected behaviour (i.e. a module adding a hook that creates trouble for the templates defined in another module), so given the lack of use cases supporting the hook and the possible negative consequences implied, it's better to remove it.
parent f429c457
No related branches found
No related tags found
No related merge requests found
...@@ -198,7 +198,6 @@ class SimpleSAML_XHTML_Template ...@@ -198,7 +198,6 @@ class SimpleSAML_XHTML_Template
$twig = new Twig_Environment($loader, $options); $twig = new Twig_Environment($loader, $options);
$twig->addExtension(new Twig_Extensions_Extension_I18n()); $twig->addExtension(new Twig_Extensions_Extension_I18n());
SimpleSAML\Module::callHooks('twigInit', $twig);
return $twig; return $twig;
} }
...@@ -476,6 +475,17 @@ class SimpleSAML_XHTML_Template ...@@ -476,6 +475,17 @@ class SimpleSAML_XHTML_Template
} }
/**
* Get the current instance of Twig in use.
*
* @return false|Twig_Environment The Twig instance in use, or false if Twig is not used.
*/
public function getTwig()
{
return $this->twig;
}
/* /*
* Deprecated methods of this interface, all of them should go away. * Deprecated methods of this interface, all of them should go away.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment