]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/response/class_BaseResponse.php
Continued:
[core.git] / framework / main / classes / response / class_BaseResponse.php
index ece0dbd269f2dc66473f46b1c7069923f06bdea6..8bc2d373d56fb01cbc139f8942f4b244c05c8042 100644 (file)
@@ -4,6 +4,7 @@ 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;
 
@@ -12,7 +13,7 @@ use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2021 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -41,23 +42,18 @@ abstract class BaseResponse extends BaseFrameworkSystem {
        /**
         * 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
         */
@@ -80,8 +76,8 @@ abstract class BaseResponse extends BaseFrameworkSystem {
         * @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;
        }
 
        /**
@@ -91,7 +87,7 @@ abstract class BaseResponse extends BaseFrameworkSystem {
         * @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;
        }
 
@@ -101,7 +97,7 @@ abstract class BaseResponse extends BaseFrameworkSystem {
         * @return      void
         */
        public final function resetResponseHeaders () {
-               $this->responseHeaders = array();
+               $this->responseHeaders = [];
        }
 
        /**
@@ -110,7 +106,7 @@ abstract class BaseResponse extends BaseFrameworkSystem {
         * @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;
        }
 
@@ -130,7 +126,7 @@ abstract class BaseResponse extends BaseFrameworkSystem {
         * @param       $responseType   Response type
         * @return      void
         */
-       protected final function setResponseType ($responseType) {
+       protected final function setResponseType (string $responseType) {
                $this->responseType = $responseType;
        }
 
@@ -151,12 +147,9 @@ abstract class BaseResponse extends BaseFrameworkSystem {
         * @param       $messageId      The message id we shall add
         * @return      void
         */
-       public final function addFatalMessage ($messageId) {
-               // Get application instance
-               $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
-
+       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));
        }
 
        /**
@@ -165,7 +158,7 @@ abstract class BaseResponse extends BaseFrameworkSystem {
         * @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);
        }
@@ -179,9 +172,9 @@ abstract class BaseResponse extends BaseFrameworkSystem {
         * @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('application');
+               $applicationInstance = ApplicationHelper::getSelfInstance();
 
                // Headers already sent?
                if ((headers_sent()) && ($force === false)) {
@@ -207,7 +200,7 @@ abstract class BaseResponse extends BaseFrameworkSystem {
                        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) {
@@ -216,8 +209,8 @@ abstract class BaseResponse extends BaseFrameworkSystem {
                                header('Set-Cookie: ' . $cookieString);
 
                                // Remove them all
-                               $this->cookies = array();
-                       } // END - if
+                               $this->cookies = [];
+                       }
                }
 
                // Are there some error messages?
@@ -244,7 +237,7 @@ abstract class BaseResponse extends BaseFrameworkSystem {
         */
        public function determineDefaultCommand () {
                // Get application instance
-               $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+               $applicationInstance = ApplicationHelper::getSelfInstance();
 
                // Generate config key
                $configKey = sprintf('default_%s_%s_command',