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