1 | <?php |
||
14 | class StorableStruct extends Struct implements StorableInterface |
||
15 | { |
||
16 | /** |
||
17 | * TRUE if structure is already marked as "dirty" into storage |
||
18 | * |
||
19 | * @var boolean |
||
20 | */ |
||
21 | protected $markedAsDirty = false; |
||
22 | /** |
||
23 | * Structures storage |
||
24 | * |
||
25 | * @var Storage |
||
26 | */ |
||
27 | private $storage; |
||
28 | /** |
||
29 | * Storage key for this structure |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | private $storageKey; |
||
34 | |||
35 | /** |
||
36 | * Class constructor |
||
37 | * |
||
38 | * @param array|object $contents OPTIONAL Contents to initialize structure with |
||
39 | * @param array|object $config OPTIONAL Configuration for this structure |
||
40 | * @throws \Flying\Struct\Exception |
||
41 | * @throws \RuntimeException |
||
42 | */ |
||
43 | 78 | public function __construct($contents = null, $config = null) |
|
58 | |||
59 | 2 | public function __clone() |
|
71 | |||
72 | /** |
||
73 | * Get key for this structure to use in structures storage |
||
74 | * |
||
75 | * @return string|null |
||
76 | * @throws \Flying\Struct\Exception |
||
77 | */ |
||
78 | 78 | public function getStorageKey() |
|
90 | |||
91 | /** |
||
92 | * Get storage container |
||
93 | * |
||
94 | * @return StorageInterface |
||
95 | * @throws \Flying\Struct\Exception |
||
96 | */ |
||
97 | 78 | protected function getStorage() |
|
119 | |||
120 | /** |
||
121 | * Get object representation suitable to put into storage |
||
122 | * |
||
123 | * @return mixed |
||
124 | */ |
||
125 | 2 | public function toStorage() |
|
129 | |||
130 | /** |
||
131 | * {@inheritdoc} |
||
132 | * @throws \Flying\Struct\Exception |
||
133 | */ |
||
134 | 30 | public function updateNotify(SimplePropertyInterface $property) |
|
142 | |||
143 | /** |
||
144 | * Get initial structure contents |
||
145 | * |
||
146 | * @param string $name OPTIONAL Structure property name to get contents of, |
||
147 | * NULL to get all available contents |
||
148 | * @return mixed |
||
149 | * @throws \Flying\Struct\Exception |
||
150 | */ |
||
151 | 78 | protected function getInitialContents($name = null) |
|
168 | |||
169 | /** |
||
170 | * Set initial structure contents |
||
171 | * |
||
172 | * @param array|object $contents |
||
173 | * @return void |
||
174 | */ |
||
175 | protected function setInitialContents($contents) |
||
179 | |||
180 | /** |
||
181 | * Create structure from given metadata information |
||
182 | * |
||
183 | * @param StructMetadata $metadata |
||
184 | * @throws Exception |
||
185 | * @return void |
||
186 | * @throws \RuntimeException |
||
187 | */ |
||
188 | 78 | protected function createStruct(StructMetadata $metadata = null) |
|
197 | |||
198 | /** |
||
199 | * {@inheritdoc} |
||
200 | * @throws \RuntimeException |
||
201 | */ |
||
202 | 1 | protected function initConfig() |
|
209 | |||
210 | /** |
||
211 | * Perform "lazy initialization" of configuration option with given name |
||
212 | * |
||
213 | * @param string $name Configuration option name |
||
214 | * @return mixed |
||
215 | * @throws \RuntimeException |
||
216 | */ |
||
217 | 78 | protected function lazyConfigInit($name) |
|
229 | |||
230 | /** |
||
231 | * Check that given value of configuration option is valid |
||
232 | * |
||
233 | * @param string $name Configuration option name |
||
234 | * @param mixed $value Option value (passed by reference) |
||
235 | * @throws \InvalidArgumentException |
||
236 | * @return boolean |
||
237 | */ |
||
238 | 78 | protected function validateConfig($name, &$value) |
|
252 | |||
253 | /** |
||
254 | * {@inheritdoc} |
||
255 | */ |
||
256 | 34 | protected function onConfigChange($name, $value) |
|
274 | } |
||
275 |