]> git.mxchange.org Git - core.git/commitdiff
getDefaultCommand() is now moved to BaseResponse.
authorRoland Haeder <roland@mxchange.org>
Tue, 24 Mar 2015 19:39:59 +0000 (20:39 +0100)
committerRoland Haeder <roland@mxchange.org>
Tue, 24 Mar 2015 19:39:59 +0000 (20:39 +0100)
Signed-off-by: Roland Häder <roland@mxchange.org>
inc/classes/main/response/class_BaseResponse.php
inc/classes/main/response/console/class_ConsoleResponse.php
inc/classes/main/response/html/class_HtmlResponse.php
inc/classes/main/response/image/class_ImageResponse.php

index bd7524890de030d6f633c3fd2de06423fd691750..6afc20fcfece706a639f921391ef1a8e629e4543 100644 (file)
@@ -50,6 +50,11 @@ class BaseResponse extends BaseFrameworkSystem {
         */
        private $templateInstance = NULL;
 
+       /**
+        * Response type
+        */
+       private $responseType = 'invalid';
+
        /**
         * Protected constructor
         *
@@ -111,6 +116,26 @@ class BaseResponse extends BaseFrameworkSystem {
                $this->responseBody = $output;
        }
 
+       /**
+        * Setter for response type
+        *
+        * @param       $responseType   Response type
+        * @return      void
+        */
+       protected final function setResponseType ($responseType) {
+               $this->responseType = $responseType;
+       }
+
+       /**
+        * Getter for response type
+        *
+        * @param       $responseType   Response type
+        * @return      void
+        */
+       public final function getResponseType () {
+               return $this->responseType;
+       }
+
        /**
         * Adds a fatal message id to the response. The added messages can then be
         * processed and outputed to the world
@@ -196,6 +221,28 @@ class BaseResponse extends BaseFrameworkSystem {
                $this->setResponseBody('');
                $this->resetResponseHeaders();
        }
+
+       /**
+        * "Getter" for default command
+        *
+        * @return      $defaultCommand         Default command for this response
+        */
+       public function getDefaultCommand () {
+               // Get application instance
+               $applicationInstance = Registry::getRegistry()->getInstance('app');
+
+               // Generate config key
+               $configKey = sprintf('default_%s_%s_command',
+                       $applicationInstance->getAppShortName(),
+                       $this->getResponseType()
+               );
+
+               // Get default command response
+               $defaultCommand = $this->getConfigInstance()->getConfigEntry($configKey);
+
+               // Return it
+               return $defaultCommand;
+       }
 }
 
 // [EOF]
index 194c0b32d668ed97adbc84c91ad5fba365f294c3..ab492d3574a3b421ae818c78d0229732575522d0 100644 (file)
@@ -33,6 +33,9 @@ class ConsoleResponse extends BaseResponse implements Responseable {
        protected function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
+
+               // Set response type
+               $this->setResponseType('image');
        }
 
        /**
@@ -115,16 +118,6 @@ class ConsoleResponse extends BaseResponse implements Responseable {
                $this->partialStub('Naturally unimplemented in console response.');
        }
 
-       /**
-        * Getter for default command
-        *
-        * @return      $defaultCommand         Default command for this response
-        */
-       public function getDefaultCommand () {
-               $defaultCommand = $this->getConfigInstance()->getConfigEntry('default_console_command');
-               return $defaultCommand;
-       }
-
        /**
         * Flushs the cached console response to the console
         *
index 4a3da75b7535f20374e519730f2288386ffd685f..ad5af0772fc037da3c8f52beeea572c045580448 100644 (file)
@@ -33,6 +33,9 @@ class HtmlResponse extends BaseResponse implements Responseable {
        protected function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
+
+               // Set response type
+               $this->setResponseType('image');
        }
 
        /**
@@ -202,16 +205,6 @@ class HtmlResponse extends BaseResponse implements Responseable {
                        $this->addCookie($cookieName, $_COOKIE[$cookieName], FALSE);
                } // END - if
        }
-
-       /**
-        * Getter for default command
-        *
-        * @return      $defaultCommand         Default command for this response
-        */
-       public function getDefaultCommand () {
-               $defaultCommand = $this->getConfigInstance()->getConfigEntry('default_html_command');
-               return $defaultCommand;
-       }
 }
 
 // [EOF]
index 0a8e92c7cdb0abe62273053be4171402e8f4648f..3cd50146d77d4307dca372598466260362d2da48 100644 (file)
@@ -33,6 +33,9 @@ class ImageResponse extends BaseResponse implements Responseable {
        protected function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
+
+               // Set response type
+               $this->setResponseType('image');
        }
 
        /**
@@ -230,16 +233,6 @@ class ImageResponse extends BaseResponse implements Responseable {
                        $this->addCookie($cookieName, $_COOKIE[$cookieName], FALSE);
                } // END - if
        }
-
-       /**
-        * Getter for default command
-        *
-        * @return      $defaultCommand         Default command for this response
-        */
-       public function getDefaultCommand () {
-               $defaultCommand = $this->getConfigInstance()->getConfigEntry('default_image_command');
-               return $defaultCommand;
-       }
 }
 
 // [EOF]