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