]> git.mxchange.org Git - friendica.git/commitdiff
Simplify the output of api results
authorMichael <heluecht@pirati.ca>
Tue, 9 Nov 2021 06:42:59 +0000 (06:42 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 9 Nov 2021 06:42:59 +0000 (06:42 +0000)
src/Module/Api/Friendica/Events/Index.php
src/Module/Api/Friendica/GNUSocial/Version.php
src/Module/Api/Friendica/Help/Test.php
src/Module/Api/Friendica/Profile/Show.php
src/Module/BaseApi.php

index 7103d1dff4d5d48db5993f95cfcbe164d8ceb374..ec8cc077aebbedd7321fd84a8e54ecc8099cea9a 100644 (file)
@@ -70,7 +70,6 @@ class Index extends BaseApi
                        ];
                }
 
-               echo self::format('events', ['events' => $items]);
-               exit;
+               self::exit('events', ['events' => $items]);
        }
 }
index 3a9bc9c56c41fce87e11ebbf6935038bdea339ce..83949de7b793215674650cae2d0c4317e751dbd6 100644 (file)
@@ -30,7 +30,6 @@ class Version extends BaseApi
 {
        public static function rawContent(array $parameters = [])
        {
-               echo self::format('version', ['version' => '0.9.7']);
-               exit;
+               self::exit('version', ['version' => '0.9.7']);
        }
 }
index 2a5ba7bf5224cb59a0009155314dc9a17cffb035..394c5e4830ac91f89e335ada11db3543938347ae 100644 (file)
@@ -36,7 +36,6 @@ class Test extends BaseApi
                        $ok = 'ok';
                }
 
-               echo self::format('ok', ['ok' => $ok]);
-               exit;
+               self::exit('ok', ['ok' => $ok]);
        }
 }
index 4167e6c61f8fcde1ea99f9191c4f889e8e63dd40..67dcfdb6e75a9996f8c164c007ab49f70fd97f40 100644 (file)
@@ -66,8 +66,7 @@ class Show extends BaseApi
                        'profiles' => $profiles
                ];
 
-               echo self::format('friendica_profiles', ['$result' => $result]);
-               exit;
+               self::exit('friendica_profiles', ['$result' => $result]);
        }
 
        /**
index 7e46931864c1a502d4ea1fed9489138dce8a99a0..75ee9ca29a7a756028b4ab43df69c4a93adfd329 100644 (file)
@@ -348,13 +348,13 @@ class BaseApi extends BaseModule
        }
 
        /**
-        * Formats the data according to the data type
+        * Outputs formatted data according to the data type and then exits the execution.
         *
         * @param string $root_element
         * @param array $data An array with a single element containing the returned result
         * @return false|string
         */
-       protected static function format(string $root_element, array $data)
+       protected static function exit(string $root_element, array $data)
        {
                $return = self::formatData($root_element, self::$format, $data);
 
@@ -382,7 +382,8 @@ class BaseApi extends BaseModule
                                break;
                }
 
-               return $return;
+               echo $return;
+               exit;
        }
 
        /**