*/
private $shortName = "";
+ /**
+ * The name of the master template
+ */
+ private $masterTemplate = "shipsimu_main";
+
+ /**
+ * An instance of a controller
+ */
+ private $controllerInstance = null;
+
/**
* An instance of this class
*/
private static $thisInstance = null;
-
/**
* Protected constructor
*
/**
* Getter for the version number
*
- * @return $appVersion The application's version number
+ * @return $appVersion The application's version number
*/
public final function getAppVersion () {
return $this->appVersion;
/**
* Setter for the version number
*
- * @param $appVersion The application's version number
+ * @param $appVersion The application's version number
* @return void
*/
public final function setAppVersion ($appVersion) {
$this->shortName = $shortName;
}
+ /**
+ * Getter for master template name
+ *
+ * @return $masterTemplate Name of the master template
+ */
+ public final function getMasterTemplate () {
+ return $this->masterTemplate;
+ }
+
/**
* Launches the ship-simulator game
*
* @return void
*/
public final function entryPoint () {
- // Handle the request
- $this->handleRequest();
+ // Create a new request object
+ $requestInstance = HttpRequest::createHttpRequest();
- // Prepare the template engine
- $tplEngine = $this->prepareTemplateEngine($this);
+ // ... and a new response object
+ $responseInstance = HttpResponse::createHttpResponse($this);
- // Load the main template
- $tplEngine->loadCodeTemplate("shipsimu_main");
+ // Get command parameter
+ $commandPara = $this->getConfigInstance()->readConfig('command_parameter');
- // Raise an error here
- trigger_error(__METHOD__.": Unfinished work!");
+ // Get the parameter from the request
+ $commandName = $requestInstance->getRequestElement($commandPara);
+
+ // If it is null then get default command
+ if (is_null($commandName)) {
+ $commandName = $this->getConfigInstance()->readConfig('default_command');
+ }
+
+ // Get a resolver
+ $resolverInstance = WebControllerResolver::createWebControllerResolver($commandName, $this);
+
+ // Get a controller instance as well
+ $this->controllerInstance = $resolverInstance->resolveCommandController();
+
+ // Handle the request
+ $this->controllerInstance->handleRequest($requestInstance, $responseInstance);
+ }
+
+ /**
+ * Handle the indexed array of fatal messages and puts them out in an
+ * acceptable fasion
+ *
+ * @param $messageList An array of fatal messages
+ * @return void
+ */
+ public function handleFatalMessages (array $messageList) {
+ // Walk through all messages
+ foreach ($messageList as $message) {
+ die("MSG:".$message);
+ }
}
}