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