1: <?php
2: /**
3: * @package OpenCart
4: *
5: * @author Daniel Kerr
6: * @copyright Copyright (c) 2005 - 2022, OpenCart, Ltd. (https://www.opencart.com/)
7: * @license https://opensource.org/licenses/GPL-3.0
8: *
9: * @see https://www.opencart.com
10: */
11: namespace Opencart\System\Library;
12: /**
13: * Class Template
14: */
15: class Template {
16: /**
17: * @var object
18: */
19: private object $adaptor;
20:
21: /**
22: * Constructor
23: *
24: * @param string $adaptor
25: */
26: public function __construct(string $adaptor) {
27: $class = 'Opencart\System\Library\Template\\' . $adaptor;
28:
29: if (class_exists($class)) {
30: $this->adaptor = new $class();
31: } else {
32: throw new \Exception('Error: Could not load template adaptor ' . $adaptor . '!');
33: }
34: }
35:
36: /**
37: * addPath
38: *
39: * @param string $namespace
40: * @param string $directory
41: *
42: * @return void
43: */
44: public function addPath(string $namespace, string $directory = ''): void {
45: $this->adaptor->addPath($namespace, $directory);
46: }
47:
48: /**
49: * Render
50: *
51: * @param string $filename
52: * @param array<string, mixed> $data
53: * @param string $code
54: *
55: * @return string
56: */
57: public function render(string $filename, array $data = [], string $code = ''): string {
58: return $this->adaptor->render($filename, $data, $code);
59: }
60: }
61: