From f79395851b044689567e0e6c9504acbcaa742782 Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Tue, 26 Feb 2019 10:11:12 +1000 Subject: Twig update to latest Twig 1.x legacy as per vichan --- inc/lib/Twig/FactoryRuntimeLoader.php | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 inc/lib/Twig/FactoryRuntimeLoader.php (limited to 'inc/lib/Twig/FactoryRuntimeLoader.php') diff --git a/inc/lib/Twig/FactoryRuntimeLoader.php b/inc/lib/Twig/FactoryRuntimeLoader.php new file mode 100644 index 00000000..2cdaded1 --- /dev/null +++ b/inc/lib/Twig/FactoryRuntimeLoader.php @@ -0,0 +1,39 @@ + + */ +class Twig_FactoryRuntimeLoader implements Twig_RuntimeLoaderInterface +{ + private $map; + + /** + * @param array $map An array where keys are class names and values factory callables + */ + public function __construct($map = array()) + { + $this->map = $map; + } + + public function load($class) + { + if (isset($this->map[$class])) { + $runtimeFactory = $this->map[$class]; + + return $runtimeFactory(); + } + } +} + +class_alias('Twig_FactoryRuntimeLoader', 'Twig\RuntimeLoader\FactoryRuntimeLoader', false); -- cgit v1.3