]> git.mxchange.org Git - friendica.git/commitdiff
Use "jsonexit"
authorMichael <heluecht@pirati.ca>
Mon, 13 Jul 2020 13:26:09 +0000 (13:26 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 13 Jul 2020 13:26:09 +0000 (13:26 +0000)
src/Core/System.php
src/Module/NodeInfo110.php
src/Module/NodeInfo120.php
src/Module/NodeInfo210.php

index feed85e211ba52836a42e00010351ed034233102..37e6d8a1cbe4da41d70be869c0b82c2fffeb3248 100644 (file)
@@ -136,12 +136,13 @@ class System
         * and adds an application/json HTTP header to the output.
         * After finishing the process is getting killed.
         *
-        * @param mixed  $x The input content.
-        * @param string $content_type Type of the input (Default: 'application/json').
+        * @param mixed   $x The input content.
+        * @param string  $content_type Type of the input (Default: 'application/json').
+        * @param integer $options JSON options
         */
-       public static function jsonExit($x, $content_type = 'application/json') {
+       public static function jsonExit($x, $content_type = 'application/json', int $options = null) {
                header("Content-type: $content_type");
-               echo json_encode($x);
+               echo json_encode($x, $options);
                exit();
        }
 
index 954f362190995d0a88088d4b30e10976ee28b9d3..79e215e4fbacd19e194f47a8d6a238a0d69970e8 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Module;
 
 use Friendica\BaseModule;
 use Friendica\Core\Addon;
+use Friendica\Core\System;
 use Friendica\DI;
 use Friendica\Model\Nodeinfo;
 
@@ -85,8 +86,6 @@ class NodeInfo110 extends BaseModule
 
                $nodeinfo['metadata']['explicitContent'] = $config->get('system', 'explicit_content', false) == true;
 
-               header('Content-type: application/json; charset=utf-8');
-               echo json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
-               exit;
+               System::jsonExit($nodeinfo, 'application/json; charset=utf-8', JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
        }
 }
index 330c5e10d5f160ef80c83f14e7dcf56864021f96..56054d7b67aae1fe820f829641d1cda7aa6c1f0e 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Module;
 
 use Friendica\BaseModule;
 use Friendica\Core\Addon;
+use Friendica\Core\System;
 use Friendica\DI;
 use Friendica\Model\Nodeinfo;
 
@@ -79,8 +80,6 @@ class NodeInfo120 extends BaseModule
 
                $nodeinfo['metadata']['explicitContent'] = $config->get('system', 'explicit_content', false) == true;
 
-               header('Content-type: application/json; charset=utf-8');
-               echo json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
-               exit;
+               System::jsonExit($nodeinfo, 'application/json; charset=utf-8', JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
        }
 }
index 63a1749832e4b2088cb1c37fb6422c7c3df8b607..a95e37fa2e89491040290a1b1d3ae79aee60a0d3 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Module;
 
 use Friendica\BaseModule;
 use Friendica\Core\Addon;
+use Friendica\Core\System;
 use Friendica\DI;
 use Friendica\Model\Nodeinfo;
 
@@ -77,8 +78,6 @@ class NodeInfo210 extends BaseModule
                        $nodeinfo['services']['inbound'][] = 'imap';
                }
 
-               header('Content-type: application/json; charset=utf-8');
-               echo json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
-               exit;
+               System::jsonExit($nodeinfo, 'application/json; charset=utf-8', JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
        }
 }