3 * An interface for responses
5 * @author Roland Haeder <webmaster@shipsimu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.shipsimu.org
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.
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.
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/>.
24 interface Responseable extends FrameworkInterface {
28 * @param $status New response status
31 function setResponseStatus ($status);
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.
40 * @param $name Name of header element
41 * @param $value Value of header element
44 function addHeader ($name, $value);
47 * "Writes" data to the response body
49 * @param $output Output we shall sent in the HTTP response
52 function writeToBody ($output);
55 * Flushs the cached HTTP response to the outer world
57 * @param $force Whether we shall force the output or abort if headers are
58 * already sent with an exception
60 * @throws ResponseHeadersAlreadySentException Thrown if headers are
63 function flushBuffer ($force = FALSE);
66 * Adds a fatal message id to the response. The added messages can then be
67 * processed and outputed to the world
69 * @param $messageId The message id we shall add
72 function addFatalMessage ($messageId);
75 * Adds a cookie to the response
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
81 * @throws ResponseHeadersAlreadySentException If headers are already sent
83 function addCookie ($cookieName, $cookieValue, $encrypted = FALSE);
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.
90 * @param $configEntry The configuration entry which holds our URL
92 * @throws ResponseHeadersAlreadySentException If headers are already sent
94 function redirectToConfiguredUrl ($configEntry);
97 * Expires the given cookie if it is set
99 * @param $cookieName Cookie to expire
102 function expireCookie ($cookieName);
105 * Refreshs a given cookie. This will make the cookie live longer
107 * @param $cookieName Cookie to refresh
110 function refreshCookie ($cookieName);