3 namespace Org\Mxchange\CoreFramework\Response;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
7 use Org\Mxchange\CoreFramework\Response\Responseable;
10 * A class for a console response aka output to console
12 * @author Roland Haeder <webmaster@shipsimu.org>
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
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.
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.
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/>.
31 * The extended headers are taken from phpMyAdmin setup tool, written by
32 * Michal Cihar <michal@cihar.com>, licensed under GNU GPL 2.0.
34 class ConsoleResponse extends BaseResponse implements Responseable {
36 * Protected constructor
40 protected function __construct () {
41 // Call parent constructor
42 parent::__construct(__CLASS__);
45 $this->setResponseType('console');
49 * Creates an object of this class
51 * @return $responseInstance A prepared instance of this class
53 public static final function createConsoleResponse () {
55 $responseInstance = new ConsoleResponse();
57 // Return the prepared instance
58 return $responseInstance;
62 * Initializes the template engine instance
64 * @param $applicationInstance An instance of a manageable application
67 public final function initTemplateEngine (ManageableApplication $applicationInstance) {
68 $this->setTemplateInstance($this->prepareTemplateInstance($applicationInstance));
72 * Adds a cookie to the response
74 * @param $cookieName Cookie's name
75 * @param $cookieValue Value to store in the cookie
76 * @param $encrypted Do some extra encryption on the value
77 * @param $expires Timestamp of expiration (default: configured)
79 * @throws ResponseHeadersAlreadySentException If headers are already sent
81 public function addCookie ($cookieName, $cookieValue, $encrypted = false, $expires = NULL) {
82 //* DEBUG: */ echo $cookieName.'='.$cookieValue."<br />\n";
83 $this->partialStub('Naturally unimplemented in console response.');
87 * Redirect to a configured URL. The URL can be absolute or relative. In
88 * case of relative URL it will be extended automatically.
90 * @param $configEntry The configuration entry which holds our URL
92 * @throws ResponseHeadersAlreadySentException If headers are already sent
94 public function redirectToConfiguredUrl ($configEntry) {
95 $this->partialStub('Naturally unimplemented in console response.');
99 * Expires the given cookie if it is set
101 * @param $cookieName Cookie to expire
104 public function expireCookie ($cookieName) {
105 $this->partialStub('Naturally unimplemented in console response.');
109 * Refreshs a given cookie. This will make the cookie live longer
111 * @param $cookieName Cookie to refresh
114 public function refreshCookie ($cookieName) {
115 $this->partialStub('Naturally unimplemented in console response.');
119 * Flushs the cached console response to the console
121 * @param $force Whether we shall force the output or abort if headers are
122 * already sent with an exception
124 * @throws ResponseHeadersAlreadySentException Thrown if headers are already sent
126 public function flushBuffer ($force = false) {
127 $this->partialStub('Please implement this class.');