]> git.mxchange.org Git - shipsimu.git/commitdiff
Fix for non-object 'request instance'
authorRoland Häder <roland@mxchange.org>
Wed, 25 Apr 2012 16:51:22 +0000 (16:51 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 25 Apr 2012 16:51:22 +0000 (16:51 +0000)
application/selector/class_ApplicationHelper.php

index 5c69c52656106656206ec340845516f54a5d2739..44d77cb62972304e3c9651a7eb0a02e86fa4cdb4 100644 (file)
@@ -175,12 +175,19 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication
                // Set this application in registry
                Registry::getRegistry()->addInstance('app', $this);
 
+               // Analyze the environment for type of response/request
+               $type = ConsoleTools::analyzeEnvironmentForType();
+               $classType = ConsoleTools::analyzeEnvironmentForClassType();
+
                // Create a new request object
-               $requestInstance = ObjectFactory::createObjectByName('HttpRequest');
+               $requestInstance = ObjectFactory::createObjectByName(ucfirst($type) . 'Request');
+
+               // Remember request instance here
+               $this->setRequestInstance($requestInstance);
 
                // Default response is HTTP (HTML page) and type is 'Web'
-               $response = 'http';
-               $responseType = 'web';
+               $response = $type;
+               $responseType = $classType;
 
                // Do we have another response?
                if ($requestInstance->isRequestElementSet('request')) {
@@ -193,8 +200,7 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication
                $responseClass = sprintf("%sResponse", $this->convertToClassName($response));
                $responseInstance = ObjectFactory::createObjectByName($responseClass, array($this));
 
-               // Remember both in this application
-               $this->setRequestInstance($requestInstance);
+               // Remember response instance here
                $this->setResponseInstance($responseInstance);
 
                // Get the parameter from the request
@@ -202,7 +208,7 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication
 
                // If it is null then get default command
                if (is_null($commandName)) {
-                       // Get default command
+                       // Get the default command
                        $commandName = $responseInstance->getDefaultCommand();
 
                        // Set it in request