mirror of
https://github.com/getgrav/grav.git
synced 2026-03-04 11:31:43 +01:00
Added new events and paths to support namespacing #1604
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user