Response.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2017 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
11 namespace wcmf\lib\presentation;
12 
13 /**
14  * Response holds the response values that are used as output from
15  * Controller instances. It is typically instantiated by the ActionMapper
16  * instance and filled during Controller execution.
17  *
18  * @author ingo herwig <ingo@wemove.com>
19  */
20 interface Response extends ControllerMessage {
21 
22  /**
23  * Set the Request instance belonging to the response and vice versa.
24  * @param $request Request
25  */
26  public function setRequest(Request $request);
27 
28  /**
29  * Get the Request instance belonging to the response.
30  * @return Request
31  */
32  public function getRequest();
33 
34  /**
35  * Set a string value that uniquely identifies the request data
36  * resulting in the current response. This value maybe used to compare
37  * two requests and return cached responses based on the result.
38  * @param $cacheId
39  */
40  public function setCacheId($cacheId);
41 
42  /**
43  * Get the cache id.
44  * @see Response::setCacheId()
45  * @return The id
46  */
47  public function getCacheId();
48 
49  /**
50  * Check if the response is cached. Controllers may use the result
51  * to determine if the controller logic must be executed or not.
52  * @return Boolean
53  */
54  public function isCached();
55 
56  /**
57  * Get the caching date, if the response is cached.
58  * @return DateTime or null, if not cached
59  */
60  public function getCacheDate();
61 
62  /**
63  * Set the response HTTP status code
64  * @param $status The HTTP status code
65  */
66  public function setStatus($status);
67 
68  /**
69  * Get the response HTTP status code
70  * @return Integer
71  */
72  public function getStatus();
73 
74  /**
75  * Set a file as response.
76  * @param $filename The name of the file, must be a real file, if no content is provided
77  * @param $isDownload Boolean, indicating whether the file should be return as download or not
78  * @param $content File content, if in-memory only (optional)
79  * @param $type File mime type, if in-memory only (optional)
80  */
81  public function setFile($filename, $isDownload, $content='', $type='');
82 
83  /**
84  * Get the file download
85  * @return Array with keys 'isDownload', 'filename', 'content' and 'type' or null
86  */
87  public function getFile();
88 }
89 ?>
Response holds the response values that are used as output from Controller instances.
Definition: Response.php:20
setRequest(Request $request)
Set the Request instance belonging to the response and vice versa.
getRequest()
Get the Request instance belonging to the response.
isCached()
Check if the response is cached.
getCacheId()
Get the cache id.
setStatus($status)
Set the response HTTP status code.
Presentation related interfaces and classes.
Definition: namespaces.php:59
setCacheId($cacheId)
Set a string value that uniquely identifies the request data resulting in the current response...
Messages are sent between Controllers and are used to transfer data between them. ...
setFile($filename, $isDownload, $content='', $type='')
Set a file as response.
Request holds the request values that are used as input to Controller instances.
Definition: Request.php:18
getCacheDate()
Get the caching date, if the response is cached.
getStatus()
Get the response HTTP status code.
getFile()
Get the file download.