]> git.mxchange.org Git - friendica.git/commitdiff
Transform ApiResponse::error() into dynamic method
authorPhilipp <admin@philipp.info>
Fri, 12 Nov 2021 19:04:47 +0000 (20:04 +0100)
committerPhilipp <admin@philipp.info>
Fri, 12 Nov 2021 19:04:47 +0000 (20:04 +0100)
include/api.php
src/Module/Api/ApiResponse.php
src/Module/Api/Friendica/Activity.php

index 346863f7412d488253054bb5f021a418a32cf6c7..4aafadfab1756fed3135c5d0241277c6bc26b1ad 100644 (file)
@@ -283,7 +283,7 @@ function api_call(App $a, App\Arguments $args = null)
                Logger::warning(API_LOG_PREFIX . 'not implemented', ['module' => 'api', 'action' => 'call', 'query' => DI::args()->getQueryString()]);
                throw new NotFoundException();
        } catch (HTTPException $e) {
-               ApiResponse::error($e->getCode(), $e->getDescription(), $e->getMessage(), $type);
+               DI::apiResponse()->error($e->getCode(), $e->getDescription(), $e->getMessage(), $type);
        }
 }
 
index 47d52ca1fc8415a56a4c5925e3d07eb6ec98601e..d09cfe3bc514f9471f9c6ae89e84684cbc8fac80 100644 (file)
@@ -135,17 +135,17 @@ class ApiResponse
         *
         * @return void
         */
-       public static function error(int $code, string $description, string $message, string $format = null)
+       public function error(int $code, string $description, string $message, string $format = null)
        {
                $error = [
                        'error'   => $message ?: $description,
                        'code'    => $code . ' ' . $description,
-                       'request' => DI::args()->getQueryString()
+                       'request' => $this->args->getQueryString()
                ];
 
                header(($_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.1') . ' ' . $code . ' ' . $description);
 
-               DI::apiResponse()->exit('status', ['status' => $error], $format);
+               $this->exit('status', ['status' => $error], $format);
        }
 
        /**
index 2f4c0ff53a83bfd81804ffb0a3e1d633543b3403..fa27876d3b4e167e17df69d07a891b00eaded1d6 100644 (file)
@@ -60,7 +60,7 @@ class Activity extends BaseApi
                        }
                        DI::apiResponse()->exit('ok', ['ok' => $ok], $parameters['extension'] ?? null);
                } else {
-                       ApiResponse::error(500, 'Error adding activity', '', $parameters['extension'] ?? null);
+                       DI::apiResponse()->error(500, 'Error adding activity', '', $parameters['extension'] ?? null);
                }
        }
 }