Support sending PSR-7 responses from controllers
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 5 Aug 2021 08:36:06 +0000 (10:36 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 5 Aug 2021 09:54:55 +0000 (11:54 +0200)
wcfsetup/install/files/lib/system/request/Request.class.php
wcfsetup/install/files/lib/system/request/RequestHandler.class.php

index b5ea9678bac046f75b5ce61d36e5abad4e424c86..6cb3304e19619432baaea027887786fc24e4c21b 100644 (file)
@@ -86,7 +86,8 @@ class Request
     {
         if ($this->requestObject === null) {
             $this->requestObject = new $this->className();
-            $this->requestObject->__run();
+
+            return $this->requestObject->__run();
         }
     }
 
index aefd18574f1f6bdf2f2b4e4a9917119e1a3365b7..74210e7966283b5ebc5328cc4562015abbdf5971 100644 (file)
@@ -2,6 +2,8 @@
 
 namespace wcf\system\request;
 
+use Laminas\HttpHandlerRunner\Emitter\SapiEmitter;
+use Psr\Http\Message\ResponseInterface;
 use wcf\system\application\ApplicationHandler;
 use wcf\system\box\BoxHandler;
 use wcf\system\exception\AJAXException;
@@ -91,7 +93,12 @@ class RequestHandler extends SingletonFactory
             $this->checkOfflineMode();
 
             // start request
-            $this->getActiveRequest()->execute();
+            $result = $this->getActiveRequest()->execute();
+
+            if ($result instanceof ResponseInterface) {
+                $emitter = new SapiEmitter();
+                $emitter->emit($result);
+            }
         } catch (NamedUserException $e) {
             $e->show();