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\Engine; |
12: | /** |
13: | * Class Controller |
14: | * |
15: | * @mixin \Opencart\System\Engine\Registry |
16: | */ |
17: | class Controller { |
18: | /** |
19: | * @var \Opencart\System\Engine\Registry |
20: | */ |
21: | protected \Opencart\System\Engine\Registry $registry; |
22: | |
23: | /** |
24: | * Constructor |
25: | * |
26: | * @param \Opencart\System\Engine\Registry $registry |
27: | */ |
28: | public function __construct(\Opencart\System\Engine\Registry $registry) { |
29: | $this->registry = $registry; |
30: | } |
31: | |
32: | /** |
33: | * __get |
34: | * |
35: | * @param string $key |
36: | * |
37: | * @return object |
38: | */ |
39: | public function __get(string $key): object { |
40: | if ($this->registry->has($key)) { |
41: | return $this->registry->get($key); |
42: | } else { |
43: | throw new \Exception('Error: Could not call registry key ' . $key . '!'); |
44: | } |
45: | } |
46: | |
47: | /** |
48: | * __set |
49: | * |
50: | * @param string $key |
51: | * @param object $value |
52: | * |
53: | * @return void |
54: | */ |
55: | public function __set(string $key, object $value): void { |
56: | $this->registry->set($key, $value); |
57: | } |
58: | } |
59: |