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. 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  * @param $filename The name of the file, must be a real file, if no content is provided
93  * @param $isDownload Boolean, indicating whether the file should be return as download or not
94  * @param $content File content, if in-memory only (optional)
95  * @param $type File mime type, if in-memory only (optional)
96  */
97  public function setFile($filename, $isDownload, $content='', $type='');
98 
99  /**
100  * Get the file download
101  * @return Array with keys 'isDownload', 'filename', 'content' and 'type' or null
102  */
103  public function getFile();
104 }
105 ?>
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.
getCacheLifetime()
Get the lifetime of a cached 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.
setCacheLifetime($seconds)
Set the lifetime of a cached response.