template.php (1010B)
1 <?php 2 /** 3 * @package OpenCart 4 * @author Daniel Kerr 5 * @copyright Copyright (c) 2005 - 2017, OpenCart, Ltd. (https://www.opencart.com/) 6 * @license https://opensource.org/licenses/GPL-3.0 7 * @link https://www.opencart.com 8 */ 9 10 /** 11 * Template class 12 */ 13 class Template { 14 private $adaptor; 15 16 /** 17 * Constructor 18 * 19 * @param string $adaptor 20 * 21 */ 22 public function __construct($adaptor) { 23 $class = 'Template\\' . $adaptor; 24 25 if (class_exists($class)) { 26 $this->adaptor = new $class(); 27 } else { 28 throw new \Exception('Error: Could not load template adaptor ' . $adaptor . '!'); 29 } 30 } 31 32 /** 33 * 34 * 35 * @param string $key 36 * @param mixed $value 37 */ 38 public function set($key, $value) { 39 $this->adaptor->set($key, $value); 40 } 41 42 /** 43 * 44 * 45 * @param string $template 46 * @param bool $cache 47 * 48 * @return string 49 */ 50 public function render($template, $cache = false) { 51 return $this->adaptor->render($template, $cache); 52 } 53 }