1 | <?php |
||
26 | class EntityOptions |
||
27 | { |
||
28 | |||
29 | use \Maslosoft\Mangan\Traits\Defaults\MongoClientOptions; |
||
30 | |||
31 | /** |
||
32 | * |
||
33 | * @var Mangan |
||
34 | */ |
||
35 | private $_mangan = null; |
||
36 | |||
37 | /** |
||
38 | * Values of this instance |
||
39 | * @var mixed[] |
||
40 | */ |
||
41 | private $_values = []; |
||
42 | private $_defaults = []; |
||
43 | |||
44 | 97 | public function __construct($model) |
|
45 | { |
||
46 | // This is to use get/set |
||
47 | 97 | foreach ($this->_getOptionNames() as $name) |
|
48 | { |
||
49 | 97 | PropertyMaker::defineProperty($this, $name, $this->_defaults); |
|
50 | } |
||
51 | |||
52 | 97 | foreach (ManganMeta::create($model)->type()->clientFlags as $name => $value) |
|
53 | { |
||
54 | 1 | $this->_values[$name] = $value; |
|
55 | } |
||
56 | 97 | $this->_mangan = Mangan::fromModel($model); |
|
57 | 97 | } |
|
58 | |||
59 | 93 | public function __get($name) |
|
60 | { |
||
61 | 93 | if (array_key_exists($name, $this->_values)) |
|
62 | { |
||
63 | 3 | return $this->_values[$name]; // We have flag set, return it |
|
64 | } |
||
65 | 91 | return $this->_mangan->$name; |
|
66 | } |
||
67 | |||
68 | 2 | public function __set($name, $value) |
|
72 | |||
73 | public function __unset($name) |
||
74 | { |
||
77 | |||
78 | public function __isset($name) |
||
82 | |||
83 | 90 | public function getSaveOptions($extraOptions = []) |
|
96 | |||
97 | } |
||
98 |