46a511484d5b4a4ce73a7c7007ef88a03858a88f
[core.git] / inc / classes / interfaces / response / class_Responseable.php
1 <?php
2 /**
3  * An interface for responses
4  *
5  * @author              Roland Haeder <webmaster@ship-simu.org>
6  * @version             0.0.0
7  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
8  * @license             GNU GPL 3.0 or any newer version
9  * @link                http://www.ship-simu.org
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23  */
24 interface Responseable extends FrameworkInterface {
25         /**
26          * Setter for status
27          *
28          * @param       $status         New response status
29          * @return      void
30          */
31         function setResponseStatus ($status);
32
33         /**
34          * Adds a header to the response. This method "wraps" the direct header()
35          * function call and so it can be done "generic". E.g. if a local
36          * application like my hub does not support redirects, this method can be
37          * kept empty or it can be done something else which would not be possible
38          * with a direct header() call.
39          *
40          * @param       $name   Name of header element
41          * @param       $value  Value of header element
42          * @return      void
43          */
44         function addHeader ($name, $value);
45
46         /**
47          * "Writes" data to the response body
48          *
49          * @param       $output         Output we shall sent in the HTTP response
50          * @return      void
51          */
52         function writeToBody ($output);
53
54         /**
55          * Flushs the cached HTTP response to the outer world
56          *
57          * @param       $force  Whether we shall force the output or abort if headers are
58          *                                      already sent with an exception
59          * @return      void
60          * @throws      ResponseHeadersAlreadySentException             Thrown if headers are
61          *                                                                                                      already sent
62          */
63         function flushBuffer ($force = FALSE);
64
65         /**
66          * Adds a fatal message id to the response. The added messages can then be
67          * processed and outputed to the world
68          *
69          * @param       $messageId      The message id we shall add
70          * @return      void
71          */
72         function addFatalMessage ($messageId);
73
74         /**
75          * Adds a cookie to the response
76          *
77          * @param       $cookieName             Cookie's name
78          * @param       $cookieValue    Value to store in the cookie
79          * @param       $encrypted              Do some extra encryption on the value
80          * @return      void
81          * @throws      ResponseHeadersAlreadySentException             If headers are already sent
82          */
83         function addCookie ($cookieName, $cookieValue, $encrypted = FALSE);
84
85         /**
86          * Redirect to a configured URL. The URL can be absolute or relative. In
87          * case of relative URL it will be extended automatically with the
88          * 'base_url' from configuration.
89          *
90          * @param       $configEntry    The configuration entry which holds our URL
91          * @return      void
92          * @throws      ResponseHeadersAlreadySentException             If headers are already sent
93          */
94         function redirectToConfiguredUrl ($configEntry);
95
96         /**
97          * Expires the given cookie if it is set
98          *
99          * @param       $cookieName             Cookie to expire
100          * @return      void
101          */
102         function expireCookie ($cookieName);
103
104         /**
105          * Refreshs a given cookie. This will make the cookie live longer
106          *
107          * @param       $cookieName             Cookie to refresh
108          * @return      void
109          */
110         function refreshCookie ($cookieName);
111 }
112
113 // [EOF]
114 ?>