diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-04-08 22:42:43 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-04-08 22:42:43 +0200 |
commit | 73ac3d0fcd3aebade34efdbca6f48520b75729d6 (patch) | |
tree | cd8760ae45b22e1df96d4f78b4de2c914643823f /lib | |
parent | c1345d3a2d7ba18859bc836f23628322b8ebc0e0 (diff) | |
parent | a1aacc18dff11351b555304a5361a73e13684bd1 (diff) | |
download | nextcloud-server-73ac3d0fcd3aebade34efdbca6f48520b75729d6.tar.gz nextcloud-server-73ac3d0fcd3aebade34efdbca6f48520b75729d6.zip |
Merge pull request #7643 from owncloud/chainable_response
Chainable Response in AppFramework
Diffstat (limited to 'lib')
-rw-r--r-- | lib/public/appframework/http/jsonresponse.php | 3 | ||||
-rw-r--r-- | lib/public/appframework/http/response.php | 13 | ||||
-rw-r--r-- | lib/public/appframework/http/templateresponse.php | 6 |
3 files changed, 22 insertions, 0 deletions
diff --git a/lib/public/appframework/http/jsonresponse.php b/lib/public/appframework/http/jsonresponse.php index b54b23a34e6..6628c4514d9 100644 --- a/lib/public/appframework/http/jsonresponse.php +++ b/lib/public/appframework/http/jsonresponse.php @@ -66,9 +66,12 @@ class JSONResponse extends Response { * Sets values in the data json array * @param array|object $data an array or object which will be transformed * to JSON + * @return JSONResponse Reference to this object */ public function setData($data){ $this->data = $data; + + return $this; } diff --git a/lib/public/appframework/http/response.php b/lib/public/appframework/http/response.php index d223621d4fd..45402d9b3b3 100644 --- a/lib/public/appframework/http/response.php +++ b/lib/public/appframework/http/response.php @@ -80,6 +80,7 @@ class Response { $this->addHeader('Cache-Control', 'no-cache, must-revalidate'); } + return $this; } @@ -88,6 +89,7 @@ class Response { * function * @param string $name The name of the HTTP header * @param string $value The value, null will delete it + * @return Response Reference to this object */ public function addHeader($name, $value) { if(is_null($value)) { @@ -95,6 +97,8 @@ class Response { } else { $this->headers[$name] = $value; } + + return $this; } @@ -130,9 +134,12 @@ class Response { /** * Set response status * @param int $status a HTTP status code, see also the STATUS constants + * @return Response Reference to this object */ public function setStatus($status) { $this->status = $status; + + return $this; } @@ -165,18 +172,24 @@ class Response { /** * Set the ETag * @param string $ETag + * @return Response Reference to this object */ public function setETag($ETag) { $this->ETag = $ETag; + + return $this; } /** * Set "last modified" date * @param \DateTime $lastModified + * @return Response Reference to this object */ public function setLastModified($lastModified) { $this->lastModified = $lastModified; + + return $this; } diff --git a/lib/public/appframework/http/templateresponse.php b/lib/public/appframework/http/templateresponse.php index 2200a38beca..f5baf788ada 100644 --- a/lib/public/appframework/http/templateresponse.php +++ b/lib/public/appframework/http/templateresponse.php @@ -74,9 +74,12 @@ class TemplateResponse extends Response { * Sets template parameters * @param array $params an array with key => value structure which sets template * variables + * @return TemplateResponse Reference to this object */ public function setParams(array $params){ $this->params = $params; + + return $this; } @@ -104,9 +107,12 @@ class TemplateResponse extends Response { * settings header and footer, user renders the normal * normal page including footer and header and blank * just renders the plain template + * @return TemplateResponse Reference to this object */ public function renderAs($renderAs){ $this->renderAs = $renderAs; + + return $this; } |