1 | <?php |
||
26 | class FormMetadataObject implements TypeInterface |
||
27 | { |
||
28 | const DATA_SET = 'set'; |
||
29 | const DATA_REMOVED = 'removed'; |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $metadata = []; |
||
35 | |||
36 | /** |
||
37 | * @var FormMetadata |
||
38 | */ |
||
39 | protected $object; |
||
40 | |||
41 | /** |
||
42 | * Contains a list of data keys that have been manipulated by the methods of |
||
43 | * this class. |
||
44 | * |
||
45 | * This is used to keep a trace of what was changed, to handle database |
||
46 | * manipulation that was done during the runtime of this request. |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | protected $touchedData = []; |
||
51 | |||
52 | /** |
||
53 | * @param string $data |
||
54 | */ |
||
55 | public function __construct($data = null) |
||
67 | |||
68 | /** |
||
69 | * @param string $key |
||
70 | * @return mixed |
||
71 | * @throws EntryNotFoundException |
||
72 | */ |
||
73 | public function get($key) |
||
81 | |||
82 | /** |
||
83 | * @param string $key |
||
84 | * @return bool |
||
85 | */ |
||
86 | public function has($key) |
||
90 | |||
91 | /** |
||
92 | * @param string $key |
||
93 | * @param mixed $value |
||
94 | */ |
||
95 | public function set($key, $value) |
||
101 | |||
102 | /** |
||
103 | * @param string $key |
||
104 | */ |
||
105 | public function remove($key) |
||
113 | |||
114 | /** |
||
115 | * Persists the last changes of this instance in database. |
||
116 | */ |
||
117 | public function persist() |
||
154 | |||
155 | /** |
||
156 | * @return array |
||
157 | */ |
||
158 | public function getMetadata() |
||
162 | |||
163 | /** |
||
164 | * @param FormMetadata $metadata |
||
165 | */ |
||
166 | public function setObject(FormMetadata $metadata) |
||
174 | |||
175 | /** |
||
176 | * @return string |
||
177 | */ |
||
178 | public function __toString() |
||
182 | |||
183 | /** |
||
184 | * @see deepClone() |
||
185 | */ |
||
186 | public function __clone() |
||
190 | |||
191 | /** |
||
192 | * When the metadata is fetched from persistence, the `metadata` array can |
||
193 | * contain object instances, meaning that by default the original references |
||
194 | * to these objects are used in the clean properties, resulting in the |
||
195 | * object modification not being detected. |
||
196 | * |
||
197 | * In this function, we clone every object that is found, to solve the issue |
||
198 | * above. |
||
199 | * |
||
200 | * @param mixed $entry |
||
201 | * @param array $path |
||
202 | */ |
||
203 | protected function deepClone($entry, array $path = []) |
||
214 | } |
||
215 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: