/** * 获取对象唯一实例 * * @param void * @return object 返回本对象实例 */ public static function getInstance() { if (!self::$_instance instanceof self) { self::$_instance = new self(); } return self::$_instance; }
/** * 控制器构造函数 * * @param array $config 配置数据数组 * @param string $controllerName 控制器名 * @param string $actionName Aciton名 */ public function __construct($config, $controllerName, $actionName) { if (empty($config)) { throw new TM_Exception("TM_Controller: config is empty"); } $this->config = $config; $this->controllerName = $controllerName; $this->actionName = $actionName; $this->request = TM_Request::getInstance(); $this->response = TM_Response::getInstance(); }