File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ protected function getFormat(): string
3434
3535 public function export (array $ data ): string
3636 {
37+ $ data = $ this ->normalizeValues ($ data );
3738 $ filename = $ this ->generateFilePath (self ::FORMAT );
3839
3940 try {
@@ -46,4 +47,24 @@ public function export(array $data): string
4647
4748 return $ filename ;
4849 }
50+
51+ // TODO: Temporary bugfix, should be extracted into a serializer/normalizer system
52+ private function normalizeValues (array $ data ): array
53+ {
54+ $ dataCount = count ($ data );
55+ for ($ i = 0 ; $ i < $ dataCount ; ++$ i ) {
56+ foreach ($ data [$ i ] as $ field => $ value ) {
57+ if ($ value instanceof \DateTime) {
58+ $ data [$ i ][$ field ] = $ value ->format (\DATE_ATOM );
59+
60+ continue ;
61+ }
62+ if (is_object ($ value ) || is_array ($ value )) {
63+ $ data [$ i ][$ field ] = json_encode ($ value );
64+ }
65+ }
66+ }
67+
68+ return $ data ;
69+ }
4970}
You can’t perform that action at this time.
0 commit comments