Added new events and paths to support namespacing #1604

This commit is contained in:
Andy Miller
2017-08-11 11:16:09 -06:00
parent 926d78d9cb
commit a37582eb4c
2 changed files with 25 additions and 0 deletions

View File

@@ -4,6 +4,8 @@
1. [](#new)
* Added a new `cache_control` system and page level property [#1591](https://github.com/getgrav/grav/issues/1591)
* Added a new `clear_images_by_default` system property to stop cache clear events from removing processed images [#1481](https://github.com/getgrav/grav/pull/1481)
* Added new `onTwigLoader()` event to enable utilization of loader methods
* Added new `Twig::addPath()` and `Twig::prependPath()` methods to wrap loader methods and support namespacing [#1604](https://github.com/getgrav/grav/issues/1604)
1. [](#bugfix)
* Allow `session.timetout` field to be set to `0` via blueprints [#1598](https://github.com/getgrav/grav/issues/1598)

View File

@@ -98,6 +98,9 @@ class Twig
$this->grav->fireEvent('onTwigTemplatePaths');
$this->loader = new \Twig_Loader_Filesystem($this->twig_paths);
$this->grav->fireEvent('onTwigLoader');
$this->loaderArray = new \Twig_Loader_Array([]);
$loader_chain = new \Twig_Loader_Chain([$this->loaderArray, $this->loader]);
@@ -359,6 +362,26 @@ class Twig
return $output;
}
/**
* Wraps the Twig_Loader_Filesystem addPath method (should be used only in `onTwigLoader()` event
* @param $template_path
* @param null $namespace
*/
public function addPath($template_path, $namespace = null)
{
$this->loader->addPath($template_path, $namespace);
}
/**
* Wraps the Twig_Loader_Filesystem prependPath method (should be used only in `onTwigLoader()` event
* @param $template_path
* @param null $namespace
*/
public function prependPath($template_path, $namespace = null)
{
$this->loader->prependPath($template_path, $namespace);
}
/**
* Simple helper method to get the twig template if it has already been set, else return
* the one being passed in