File tree 2 files changed +41
-1
lines changed
2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
namespace Burgov \Bundle \KeyValueFormBundle \Form \DataTransformer ;
3
3
4
+ use Burgov \Bundle \KeyValueFormBundle \KeyValueContainer ;
4
5
use Symfony \Component \Form \DataTransformerInterface ;
5
6
use Symfony \Component \Form \Exception \TransformationFailedException ;
6
7
@@ -18,7 +19,7 @@ public function transform($value)
18
19
19
20
public function reverseTransform ($ value )
20
21
{
21
- $ return = array ();
22
+ $ return = new KeyValueContainer ();
22
23
23
24
foreach ($ value as $ data ) {
24
25
if (array ('key ' , 'value ' ) != array_keys ($ data )) {
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Burgov \Bundle \KeyValueFormBundle ;
4
+
5
+ class KeyValueContainer implements \ArrayAccess
6
+ {
7
+ private $ data ;
8
+
9
+ public function __construct (array $ data = array ())
10
+ {
11
+ $ this ->data = $ data ;
12
+ }
13
+
14
+ public function toArray ()
15
+ {
16
+ return $ this ->data ;
17
+ }
18
+
19
+ public function offsetExists ($ offset )
20
+ {
21
+ return array_key_exists ($ offset , $ this ->data );
22
+ }
23
+
24
+ public function offsetGet ($ offset )
25
+ {
26
+ return $ this ->data [$ offset ];
27
+ }
28
+
29
+ public function offsetSet ($ offset , $ value )
30
+ {
31
+ $ this ->data [$ offset ] = $ value ;
32
+ }
33
+
34
+ public function offsetUnset ($ offset )
35
+ {
36
+ unset($ this ->data [$ offset ]);
37
+ }
38
+ }
39
+
You can’t perform that action at this time.
0 commit comments