namespace Org\Mxchange\CoreFramework\Response;
// Import framework stuff
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
/**
* A generic request class
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
/**
* Array with all headers
*/
- private $responseHeaders = array();
+ private $responseHeaders = [];
/**
* Cookies we shall sent out
*/
- private $cookies = array();
+ private $cookies = [];
/**
* Body of the response
*/
private $responseBody = '';
- /**
- * Instance of the template engine
- */
- private $templateInstance = NULL;
-
/**
* Response type
*/
* @param $className Name of the concrete response
* @return void
*/
- protected function __construct ($className) {
+ protected function __construct (string $className) {
// Call parent constructor
parent::__construct($className);
}
* @param $status New response status
* @return void
*/
- public final function setResponseStatus ($status) {
- $this->responseStatus = (string) $status;
+ public final function setResponseStatus (string $status) {
+ $this->responseStatus = $status;
}
/**
* @param $value Value of header element
* @return void
*/
- public final function addHeader ($name, $value) {
+ public final function addHeader (string $name, $value) {
$this->responseHeaders[$name] = $value;
}
* @return void
*/
public final function resetResponseHeaders () {
- $this->responseHeaders = array();
+ $this->responseHeaders = [];
}
/**
* @param $output Output we shall sent in the HTTP response
* @return void
*/
- public final function writeToBody ($output) {
+ public final function writeToBody (string $output) {
$this->responseBody .= $output;
}
* @param $responseType Response type
* @return void
*/
- protected final function setResponseType ($responseType) {
+ protected final function setResponseType (string $responseType) {
$this->responseType = $responseType;
}
* @param $messageId The message id we shall add
* @return void
*/
- public final function addFatalMessage ($messageId) {
- // Get application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('app');
-
+ public final function addFatalMessage (string $messageId) {
// Adds the resolved message id to the fatal message list
- $this->addFatalMessagePlain($applicationInstance()->getLanguageInstance()->getMessage($messageId));
+ $this->addFatalMessagePlain(FrameworkBootstrap::getLanguageInstance()->getMessage($messageId));
}
/**
* @param $message The plain message we shall add
* @return void
*/
- public final function addFatalMessagePlain ($message) {
+ public final function addFatalMessagePlain (string $message) {
// Adds the resolved message id to the fatal message list
$this->pushValueToGenericArrayKey('fatal_messages', 'generic', 'message', $message);
}
* @throws ResponseHeadersAlreadySentException Thrown if headers are
* already sent
*/
- public function flushBuffer ($force = false) {
+ public function flushBuffer (bool $force = false) {
// Get application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('app');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Headers already sent?
if ((headers_sent()) && ($force === false)) {
$this->addHeader('Pragma', 'no-cache'); // HTTP/1.0
// Define the charset to be used
- //$this->addHeader('Content-type:', sprintf("text/html; charset=%s", $this->getConfigInstance()->getConfigEntry('header_charset')));
+ //$this->addHeader('Content-type:', sprintf("text/html; charset=%s", FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('header_charset')));
// Send all headers
foreach ($this->responseHeaders as $name => $value) {
header($name . ': ' . $value);
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('name=' . $name . ',value=' . $value);
- } // END - foreach
+ }
// Send cookies out?
if (count($this->cookies) > 0) {
header('Set-Cookie: ' . $cookieString);
// Remove them all
- $this->cookies = array();
- } // END - if
+ $this->cookies = [];
+ }
}
// Are there some error messages?
$this->getWebOutputInstance()->output($this->responseBody);
} else {
// Display all error messages
- $applicationInstance()->handleFatalMessages($this->getGenericArrayKey('fatal_messages', 'generic', 'message'));
+ $applicationInstance->handleFatalMessages($this->getGenericArrayKey('fatal_messages', 'generic', 'message'));
// Send the error messages out to the world
$this->getWebOutputInstance()->output($this->responseBody);
*/
public function determineDefaultCommand () {
// Get application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('app');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Generate config key
$configKey = sprintf('default_%s_%s_command',
);
// Get default command response
- $defaultCommand = $this->getConfigInstance()->getConfigEntry($configKey);
+ $defaultCommand = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configKey);
// Return it
return $defaultCommand;