Back to Opencart

File system\engine\model.php

docs/api/source-system.engine.model.html

4.1.0.34.3 KB
Original Source

Namespaces

Classes

| 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: | | | 12: | /** | | 13: | * Model class | | 14: | */ | | 15: | namespace Opencart\System\Engine; | | 16: | /** | | 17: | * Class Model | | 18: | * | | 19: | * @mixin \Opencart\System\Engine\Registry | | 20: | */ | | 21: | class Model { | | 22: | /** | | 23: | * @var \Opencart\System\Engine\Registry | | 24: | */ | | 25: | protected \Opencart\System\Engine\Registry $registry; | | 26: | | | 27: | /** | | 28: | * Constructor | | 29: | * | | 30: | * @param \Opencart\System\Engine\Registry $registry | | 31: | */ | | 32: | public function __construct(\Opencart\System\Engine\Registry $registry) { | | 33: | $this->registry = $registry; | | 34: | } | | 35: | | | 36: | /** | | 37: | * __get | | 38: | * | | 39: | * @param string $key | | 40: | * | | 41: | * @return object | | 42: | */ | | 43: | public function __get(string $key): object { | | 44: | if ($this->registry->has($key)) { | | 45: | return $this->registry->get($key); | | 46: | } else { | | 47: | throw new \Exception('Error: Could not call registry key ' . $key . '!'); | | 48: | } | | 49: | } | | 50: | | | 51: | /** | | 52: | * __set | | 53: | * | | 54: | * @param string $key | | 55: | * @param object $value | | 56: | * | | 57: | * @return void | | 58: | */ | | 59: | public function __set(string $key, object $value): void { | | 60: | $this->registry->set($key, $value); | | 61: | } | | 62: | | | 63: | /** | | 64: | * __isset | | 65: | * | | 66: | * https://www.php.net/manual/en/language.oop5.overloading.php#object.set | | 67: | * | | 68: | * @param string $key | | 69: | * | | 70: | * @return bool | | 71: | */ | | 72: | public function __isset(string $key): bool { | | 73: | return $this->registry->has($key); | | 74: | } | | 75: | } | | 76: | |

OpenCart API API documentation generated by ApiGen dev-master