5fd6b50cc4a613fc6f9c7b75fefbe8065fabde7d
[shipsimu.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, this is free software
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          * Add header element
35          *
36          * @param       $name   Name of header element
37          * @param       $value  Value of header element
38          * @return      void
39          */
40         function addHeader ($name, $value);
41
42         /**
43          * "Writes" data to the response body
44          *
45          * @param       $output         Output we shall sent in the HTTP response
46          * @return      void
47          */
48         function writeToBody ($output);
49
50         /**
51          * Flushs the cached HTTP response to the outer world
52          *
53          * @param       $foce   Wether we shall force the output or abort if headers are
54          *                                      already sent with an exception
55          * @return      void
56          * @throws      ResponseHeadersAlreadySentException             Thrown if headers are
57          *                                                                                                      already sent
58          */
59         function flushBuffer ($force = false);
60
61         /**
62          * Adds a fatal message id to the response. The added messages can then be
63          * processed and outputed to the world
64          *
65          * @param       $messageId      The message id we shall add
66          * @return      void
67          */
68         function addFatalMessage ($messageId);
69
70         /**
71          * Adds a cookie to the response
72          *
73          * @param       $cookieName             Cookie's name
74          * @param       $cookieValue    Value to store in the cookie
75          * @param       $encrypted              Do some extra encryption on the value
76          * @return      void
77          * @throws      ResponseHeadersAlreadySentException             If headers are already sent
78          */
79         function addCookie ($cookieName, $cookieValue, $encrypted = false);
80
81         /**
82          * Redirect to a configured URL. The URL can be absolute or relative. In
83          * case of relative URL it will be extended automatically.
84          *
85          * @param       $configEntry    The configuration entry which holds our URL
86          * @return      void
87          * @throws      ResponseHeadersAlreadySentException             If headers are already sent
88          */
89         function redirectToConfiguredUrl ($configEntry);
90 }
91
92 //
93 ?>