]> source.dussan.org Git - nextcloud-server.git/commitdiff
Move NotFoundResponse to a proper TemplateResponse 21987/head
authorJulius Härtl <jus@bitgrid.net>
Fri, 24 Jul 2020 05:53:48 +0000 (07:53 +0200)
committerJulius Härtl <jus@bitgrid.net>
Fri, 24 Jul 2020 06:58:14 +0000 (08:58 +0200)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
lib/private/AppFramework/Middleware/AdditionalScriptsMiddleware.php
lib/public/AppFramework/Http/NotFoundResponse.php

index 619432be78fd8d5dfc579504f4cf6de3b43b3e04..9eafd5b740c9d30c8f3c714ca000ae4156296bc7 100644 (file)
@@ -53,16 +53,15 @@ class AdditionalScriptsMiddleware extends Middleware {
        }
 
        public function afterController($controller, $methodName, Response $response): Response {
-               /*
-                * There is no need to emit these signals on a public share page
-                * There is a separate event for that already
-                */
-               if ($controller instanceof PublicShareController) {
-                       return $response;
-               }
-
                if ($response instanceof TemplateResponse) {
-                       $this->legacyDispatcher->dispatch(TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS, new GenericEvent());
+                       if (!$controller instanceof PublicShareController) {
+                               /*
+                                * The old event was not dispatched on the public share controller as there was
+                                * OCA\Files_Sharing::loadAdditionalScripts for that. This is kept for compatibility reasons
+                                * only for the old event as this is now also included in BeforeTemplateRenderedEvent
+                                */
+                               $this->legacyDispatcher->dispatch(TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS, new GenericEvent());
+                       }
 
                        if (!($response instanceof StandaloneTemplateResponse) && $this->userSession->isLoggedIn()) {
                                $this->legacyDispatcher->dispatch(TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN, new GenericEvent());
index ffebfdf3c76a01fcceac685660f125646dca7b98..9bf08443a89d8432fd7fa7c8babfe59310e3f2af 100644 (file)
 
 namespace OCP\AppFramework\Http;
 
-use OCP\Template;
-
 /**
  * A generic 404 response showing an 404 error page as well to the end-user
  * @since 8.1.0
  */
-class NotFoundResponse extends Response {
+class NotFoundResponse extends TemplateResponse {
 
        /**
         * @since 8.1.0
         */
        public function __construct() {
-               parent::__construct();
+               parent::__construct('core', '404', [], 'guest');
 
                $this->setContentSecurityPolicy(new ContentSecurityPolicy());
                $this->setStatus(404);
        }
-
-       /**
-        * @return string
-        * @since 8.1.0
-        */
-       public function render() {
-               $template = new Template('core', '404', 'guest');
-               return $template->fetchPage();
-       }
 }