Response.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2020 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. If this value is not null,
37  * it will be used to compare two requests and return cached responses
38  * based on the result. Set a value of null to prevent caching.
39  * @param $cacheId
40  */
41  public function setCacheId($cacheId);
42 
43  /**
44  * Get the cache id.
45  * @see Response::setCacheId()
46  * @return The id
47  */
48  public function getCacheId();
49 
50  /**
51  * Set the lifetime of a cached response. After this time
52  * previously cached response is dicarded. Set a value of -1 for
53  * an infinite lifetime.
54  * @param $seconds
55  */
56  public function setCacheLifetime($seconds);
57 
58  /**
59  * Get the lifetime of a cached response. A value of null means
60  * an infinite lifetime.
61  * @return Integer
62  */
63  public function getCacheLifetime();
64 
65  /**
66  * Check if the response is cached. Controllers may use the result
67  * to determine if the controller logic must be executed or not.
68  * @return Boolean
69  */
70  public function isCached();
71 
72  /**
73  * Get the caching date, if the response is cached.
74  * @return DateTime or null, if not cached
75  */
76  public function getCacheDate();
77 
78  /**
79  * Set the response HTTP status code
80  * @param $status The HTTP status code
81  */
82  public function setStatus($status);
83 
84  /**
85  * Get the response HTTP status code
86  * @return Integer
87  */
88  public function getStatus();
89 
90  /**
91  * Set a file as response
92  * @deprecated Use setDocument() instead
93  * @param $filename The name of the file, must be a real file, if no content is provided
94  * @param $isDownload Boolean, indicating whether the file should be return as download or not
95  * @param $content File content, if in-memory only (optional)
96  * @param $type File mime type, if in-memory only (optional)
97  */
98  public function setFile($filename, $isDownload, $content='', $type='');
99 
100  /**
101  * Get the file download
102  * @deprecated Use getDocument() instead
103  * @return Array with keys 'isDownload', 'filename', 'content' and 'type' or null
104  */
105  public function getFile();
106 
107  /**
108  * Set a response document
109  * @param $document The ResponseDocument instance
110  */
111  public function setDocument(ResponseDocument $document);
112 
113  /**
114  * Get the response document
115  * @return ResponseDocument
116  */
117  public function getDocument();
118 }
119 ?>
Response holds the response values that are used as output from Controller instances.
Definition: Response.php:20
Request holds the request values that are used as input to Controller instances.
Definition: Request.php:18
setDocument(ResponseDocument $document)
Set a response document.
getCacheId()
Get the cache id.
getRequest()
Get the Request instance belonging to the response.
setCacheLifetime($seconds)
Set the lifetime of a cached response.
getFile()
Get the file download.
setFile($filename, $isDownload, $content='', $type='')
Set a file as response.
ResponseDocument is the interface for media returned in a response when using the DownloadFormat.
isCached()
Check if the response is cached.
Messages are sent between Controllers and are used to transfer data between them.
setRequest(Request $request)
Set the Request instance belonging to the response and vice versa.
getCacheLifetime()
Get the lifetime of a cached response.
setStatus($status)
Set the response HTTP status code.
setCacheId($cacheId)
Set a string value that uniquely identifies the request data resulting in the current response.
getDocument()
Get the response document.
getStatus()
Get the response HTTP status code.
Presentation related interfaces and classes.
Definition: namespaces.php:59
getCacheDate()
Get the caching date, if the response is cached.