Browse Source

Use PSR7 response methods where possible.

In Component callbacks that return a response we can start using the
PSR7 methods as the event dispatcher passes the returned response up the
stack and eventually emits it.

Refs #9636
Mark Story 9 years ago
parent
commit
549cb2007b

+ 4 - 6
src/Controller/Component/AuthComponent.php

@@ -366,8 +366,9 @@ class AuthComponent extends Component
         if (empty($this->_authenticateObjects)) {
             $this->constructAuthenticate();
         }
+        $response = $this->response;
         $auth = end($this->_authenticateObjects);
-        $result = $auth->unauthenticated($this->request, $this->response);
+        $result = $auth->unauthenticated($this->request, $response);
         if ($result !== null) {
             return $result;
         }
@@ -384,13 +385,10 @@ class AuthComponent extends Component
                 $this->_config['ajaxLogin'],
                 $this->RequestHandler->ajaxLayout
             );
-            $response->statusCode(403);
-
-            return $response;
+            return $response->withStatus(403);
         }
-        $this->response->statusCode(403);
 
-        return $this->response;
+        return $response->withStatus(403);
     }
 
     /**

+ 1 - 2
src/Controller/Component/RequestHandlerComponent.php

@@ -288,9 +288,8 @@ class RequestHandlerComponent extends Component
             'query' => $query,
             'cookies' => $request->cookies
         ]));
-        $response->statusCode(200);
 
-        return $response;
+        return $response->withStatus(200);
     }
 
     /**