]> git.mxchange.org Git - core.git/blob - framework/main/classes/response/console/class_ConsoleResponse.php
Continued:
[core.git] / framework / main / classes / response / console / class_ConsoleResponse.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\Response;
4
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
7 use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
8 use Org\Mxchange\CoreFramework\Response\Responseable;
9
10 /**
11  * A class for a console response aka output to console
12  *
13  * @author              Roland Haeder <webmaster@shipsimu.org>
14  * @version             0.0.0
15  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
16  * @license             GNU GPL 3.0 or any newer version
17  * @link                http://www.shipsimu.org
18  *
19  * This program is free software: you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation, either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  * The extended headers are taken from phpMyAdmin setup tool, written by
33  * Michal Cihar <michal@cihar.com>, licensed under GNU GPL 2.0.
34  */
35 class ConsoleResponse extends BaseResponse implements Responseable {
36         /**
37          * Protected constructor
38          *
39          * @return      void
40          */
41         private function __construct () {
42                 // Call parent constructor
43                 parent::__construct(__CLASS__);
44
45                 // Set response type
46                 $this->setResponseType('console');
47         }
48
49         /**
50          * Creates an object of this class
51          *
52          * @return      $responseInstance       A prepared instance of this class
53          */
54         public static final function createConsoleResponse () {
55                 // Get a new instance
56                 $responseInstance = new ConsoleResponse();
57
58                 // Return the prepared instance
59                 return $responseInstance;
60         }
61
62         /**
63          * Adds a cookie to the response
64          *
65          * @param       $cookieName             Cookie's name
66          * @param       $cookieValue    Value to store in the cookie
67          * @param       $encrypted              Do some extra encryption on the value
68          * @param       $expires                Timestamp of expiration (default: configured)
69          * @return      void
70          * @throws      ResponseHeadersAlreadySentException             If headers are already sent
71          */
72         public function addCookie (string $cookieName, $cookieValue, bool $encrypted = FALSE, int $expires = NULL) {
73                 //* DEBUG: */ echo $cookieName.'='.$cookieValue."<br />\n";
74                 DebugMiddleware::getSelfInstance()->partialStub('Naturally unimplemented in console response.');
75         }
76
77         /**
78          * Redirect to a configured URL. The URL can be absolute or relative. In
79          * case of relative URL it will be extended automatically.
80          *
81          * @param       $configEntry    The configuration entry which holds our URL
82          * @return      void
83          * @throws      ResponseHeadersAlreadySentException             If headers are already sent
84          */
85         public function redirectToConfiguredUrl ($configEntry) {
86                 DebugMiddleware::getSelfInstance()->partialStub('Naturally unimplemented in console response.');
87         }
88
89         /**
90          * Expires the given cookie if it is set
91          *
92          * @param       $cookieName             Cookie to expire
93          * @return      void
94          */
95         public function expireCookie ($cookieName) {
96                 DebugMiddleware::getSelfInstance()->partialStub('Naturally unimplemented in console response.');
97         }
98
99         /**
100          * Refreshs a given cookie. This will make the cookie live longer
101          *
102          * @param       $cookieName             Cookie to refresh
103          * @return      void
104          */
105         public function refreshCookie ($cookieName) {
106                 DebugMiddleware::getSelfInstance()->partialStub('Naturally unimplemented in console response.');
107         }
108
109         /**
110          * Flushs the cached console response to the console
111          *
112          * @param       $force  Whether we shall force the output or abort if headers are
113          *                                      already sent with an exception
114          * @return      void
115          * @throws      ResponseHeadersAlreadySentException             Thrown if headers are already sent
116          */
117         public function flushBuffer ($force = false) {
118                 DebugMiddleware::getSelfInstance()->partialStub('Please implement this class.');
119         }
120
121 }