* @package TinyMVC * @version $Id$ * */ /** * Request abstract class * @package TinyMVC */ abstract class TinyMVCRequest { protected $paramArray; protected $sessionArray; static protected $instance = null; private $dispatched = false; private function __construct() { } final private function __clone() { } /** * get parameter value by given key * @param string $key parameter key * @param mixed $nullValue return value for non-existent key * @return mixed parametr value */ public function getParam($key, $nullValue = null) { return array_key_exists($key, $this->paramArray) ? $this->paramArray[$key] : $nullValue; } /** * set parameter value * @param string $key parameter key * @param mixed $value parameter value */ public function setParam($key, $value) { $this->paramArray[$key] = $value; } /** * get session parameter value by given key * @param string $key session key * @param mixed $nullValue return value for non-existent key * @return mixed session value */ public function getSessionParam($key, $nullValue = null) { return array_key_exists($key, $this->sessionArray) ? $this->sessionArray[$key] : $nullValue; } /** * check whether or not session is registered * @param string $key session key * @return bool */ public function isSessionRegistered($key) { return array_key_exists($key, $this->sessionArray[$key]) ? true : false; } /** * set session parameter * @param string $key session key * @param mixed $value session value */ public function setSessionParam($key, $value) { $this->sessionArray[$key] = $value; } /** * remove session parameter by key * @param string $key session key */ public function sessionUnregister($key) { unset($this->sessionArray[$key]); } /** * get all parameters * @return array key => value parameters array */ public function getParams() { return $this->paramArray; } /** * get all session params * @return array key => value session parameters array */ public function getSessionParams() { return $this->sessionArray; } public function setDispatched(){ $this->dispatched = true; } public function isDispatched(){ return $this->dispatched; } }