From eb23105bef52d3bf706abe6f225170d8e143339e Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 24 Mar 2015 20:39:59 +0100 Subject: [PATCH] getDefaultCommand() is now moved to BaseResponse. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../main/response/class_BaseResponse.php | 47 +++++++++++++++++++ .../console/class_ConsoleResponse.php | 13 ++--- .../main/response/html/class_HtmlResponse.php | 13 ++--- .../response/image/class_ImageResponse.php | 13 ++--- 4 files changed, 56 insertions(+), 30 deletions(-) diff --git a/inc/classes/main/response/class_BaseResponse.php b/inc/classes/main/response/class_BaseResponse.php index bd752489..6afc20fc 100644 --- a/inc/classes/main/response/class_BaseResponse.php +++ b/inc/classes/main/response/class_BaseResponse.php @@ -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] diff --git a/inc/classes/main/response/console/class_ConsoleResponse.php b/inc/classes/main/response/console/class_ConsoleResponse.php index 194c0b32..ab492d35 100644 --- a/inc/classes/main/response/console/class_ConsoleResponse.php +++ b/inc/classes/main/response/console/class_ConsoleResponse.php @@ -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 * diff --git a/inc/classes/main/response/html/class_HtmlResponse.php b/inc/classes/main/response/html/class_HtmlResponse.php index 4a3da75b..ad5af077 100644 --- a/inc/classes/main/response/html/class_HtmlResponse.php +++ b/inc/classes/main/response/html/class_HtmlResponse.php @@ -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] diff --git a/inc/classes/main/response/image/class_ImageResponse.php b/inc/classes/main/response/image/class_ImageResponse.php index 0a8e92c7..3cd50146 100644 --- a/inc/classes/main/response/image/class_ImageResponse.php +++ b/inc/classes/main/response/image/class_ImageResponse.php @@ -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] -- 2.39.5