1 | <?php |
||
23 | class FormMetadataObject implements TypeInterface |
||
24 | { |
||
25 | /** |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $metadata = []; |
||
29 | |||
30 | /** |
||
31 | * @param array $data |
||
32 | */ |
||
33 | public function __construct($data = null) |
||
45 | |||
46 | /** |
||
47 | * @param string $key |
||
48 | * @return mixed |
||
49 | * @throws EntryNotFoundException |
||
50 | */ |
||
51 | public function get($key) |
||
59 | |||
60 | /** |
||
61 | * @param string $key |
||
62 | * @return bool |
||
63 | */ |
||
64 | public function has($key) |
||
68 | |||
69 | /** |
||
70 | * @param string $key |
||
71 | * @param mixed $value |
||
72 | */ |
||
73 | public function set($key, $value) |
||
77 | |||
78 | /** |
||
79 | * @param string $key |
||
80 | */ |
||
81 | public function remove($key) |
||
87 | |||
88 | /** |
||
89 | * @return array |
||
90 | */ |
||
91 | public function getMetadata() |
||
95 | |||
96 | /** |
||
97 | * @return string |
||
98 | */ |
||
99 | public function __toString() |
||
103 | |||
104 | /** |
||
105 | * @see deepClone() |
||
106 | */ |
||
107 | public function __clone() |
||
111 | |||
112 | /** |
||
113 | * When the metadata is fetched from persistence, the `metadata` array can |
||
114 | * contain object instances, meaning that by default the original references |
||
115 | * to these objects are used in the clean properties, resulting in the |
||
116 | * object modification not being detected. |
||
117 | * |
||
118 | * In this function, we clone every object that is found, to solve the issue |
||
119 | * above. |
||
120 | * |
||
121 | * @param mixed $entry |
||
122 | * @param array $path |
||
123 | */ |
||
124 | protected function deepClone($entry, array $path = []) |
||
135 | } |
||
136 |