aboutsummaryrefslogtreecommitdiff
path: root/app/class/wflywheel/formatter/json.php
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2018-12-15 16:23:19 +0100
committervincent-peugnet <v.peugnet@free.fr>2018-12-15 16:23:19 +0100
commitc4a005a69a854682f064016d428d23e50c6e9dee (patch)
tree01ca79b09fb7ca7ad7c3be2ded4f5b323e5b3cb5 /app/class/wflywheel/formatter/json.php
parentfbe5d2beb2bcc7035edc19eb0343f0ee662ba5af (diff)
downloadwcms-c4a005a69a854682f064016d428d23e50c6e9dee.tar.gz
wcms-c4a005a69a854682f064016d428d23e50c6e9dee.zip
Flywheel extension and custom json formatter
Diffstat (limited to 'app/class/wflywheel/formatter/json.php')
-rw-r--r--app/class/wflywheel/formatter/json.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/class/wflywheel/formatter/json.php b/app/class/wflywheel/formatter/json.php
new file mode 100644
index 0000000..8583802
--- /dev/null
+++ b/app/class/wflywheel/formatter/json.php
@@ -0,0 +1,20 @@
+<?php
+namespace WFlywheel\Formatter;
+
+class JSON implements \JamesMoss\Flywheel\Formatter\FormatInterface
+{
+ public function getFileExtension()
+ {
+ return 'json';
+ }
+ public function encode(array $data)
+ {
+ $options = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null;
+ return json_encode($data, $options);
+ }
+ public function decode($data)
+ {
+ $options = defined('JSON_OBJECT_AS_ARRAY') ? JSON_OBJECT_AS_ARRAY : null;
+ return json_decode($data, $options);
+ }
+} \ No newline at end of file