]> git.mxchange.org Git - shipsimu.git/blobdiff - application/ship-simu/class_ApplicationHelper.php
More object are configureable, cache initially added
[shipsimu.git] / application / ship-simu / class_ApplicationHelper.php
index 75373862f40ca89aeb65ecd34ed0ef64a1781c05..6a94ebad143e1dacfa49d7943a7f1039cee40ed8 100644 (file)
@@ -60,11 +60,15 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
         */
        private $masterTemplate = "shipsimu_main";
 
+       /**
+        * An instance of a controller
+        */
+       private $controllerInstance = null;
+
        /**
         * An instance of this class
         */
        private static $thisInstance = null;
-
        /**
         * Protected constructor
         *
@@ -178,22 +182,44 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
         */
        public final function entryPoint () {
                // Create a new request object
-               $requestInstance = HttpRequest::createHttpRequest();
+               $requestInstance = ObjectFactory::createObjectByName('HttpRequest');
 
                // ... and a new response object
                $responseInstance = HttpResponse::createHttpResponse($this);
 
-               // Get default command
-               $defaultCommand = $this->getConfigInstance()->readConfig("default_command");
+               // Get command parameter
+               $commandPara = $this->getConfigInstance()->readConfig('command_parameter');
+
+               // 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($defaultCommand, $this);
+               $resolverInstance = WebControllerResolver::createWebControllerResolver($commandName, $this);
 
-               // Get a new controller instance as well
-               $controllerInstance = $resolverInstance->resolveDefaultController();
+               // Get a controller instance as well
+               $this->controllerInstance = $resolverInstance->resolveCommandController();
 
                // Handle the request
-               $controllerInstance->handleRequest($requestInstance, $responseInstance);
+               $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);
+               }
        }
 }