]> git.mxchange.org Git - friendica.git/blobdiff - src/BaseModule.php
Fix Tos Module
[friendica.git] / src / BaseModule.php
index 1bf100df69518661d62b064ce3486671abda55d4..86dd5e7c064d1d83b035da29ba91ec6ccc5e5543 100644 (file)
@@ -24,7 +24,6 @@ namespace Friendica;
 use Friendica\App\Router;
 use Friendica\Capabilities\ICanHandleRequests;
 use Friendica\Capabilities\ICanCreateResponses;
-use Friendica\Capabilities\IRespondToRequests;
 use Friendica\Core\Hook;
 use Friendica\Core\L10n;
 use Friendica\Core\Logger;
@@ -33,6 +32,7 @@ use Friendica\Module\Response;
 use Friendica\Module\Special\HTTPException as ModuleHTTPException;
 use Friendica\Network\HTTPException;
 use Friendica\Util\Profiler;
+use Psr\Http\Message\ResponseInterface;
 use Psr\Log\LoggerInterface;
 
 /**
@@ -171,7 +171,7 @@ abstract class BaseModule implements ICanHandleRequests
        /**
         * {@inheritDoc}
         */
-       public function run(array $post = [], array $request = []): IRespondToRequests
+       public function run(array $post = [], array $request = []): ResponseInterface
        {
                // @see https://github.com/tootsuite/mastodon/blob/c3aef491d66aec743a3a53e934a494f653745b61/config/initializers/cors.rb
                if (substr($request['pagename'] ?? '', 0, 12) == '.well-known/') {
@@ -220,26 +220,25 @@ abstract class BaseModule implements ICanHandleRequests
                        case Router::PUT:
                                $this->put();
                                break;
-                       default:
-                               $timestamp = microtime(true);
-                               // "rawContent" is especially meant for technical endpoints.
-                               // This endpoint doesn't need any theme initialization or other comparable stuff.
-                               $this->rawContent($request);
-
-                               try {
-                                       $arr = ['content' => ''];
-                                       Hook::callAll(static::class . '_mod_content', $arr);
-                                       $this->response->addContent($arr['content']);
-                                       $this->response->addContent($this->content($_REQUEST));
-                               } catch (HTTPException $e) {
-                                       $this->response->addContent((new ModuleHTTPException())->content($e));
-                               } finally {
-                                       $this->profiler->set(microtime(true) - $timestamp, 'content');
-                               }
-                               break;
                }
 
-               return $this->response;
+               $timestamp = microtime(true);
+               // "rawContent" is especially meant for technical endpoints.
+               // This endpoint doesn't need any theme initialization or other comparable stuff.
+               $this->rawContent($request);
+
+               try {
+                       $arr = ['content' => ''];
+                       Hook::callAll(static::class . '_mod_content', $arr);
+                       $this->response->addContent($arr['content']);
+                       $this->response->addContent($this->content($_REQUEST));
+               } catch (HTTPException $e) {
+                       $this->response->addContent((new ModuleHTTPException())->content($e));
+               } finally {
+                       $this->profiler->set(microtime(true) - $timestamp, 'content');
+               }
+
+               return $this->response->generate();
        }
 
        /*