From: Roland Häder Date: Wed, 25 Apr 2012 16:51:22 +0000 (+0000) Subject: Fix for non-object 'request instance' X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7e299c77a502f06e0806e6cbe2292c29b941e4d1;p=shipsimu.git Fix for non-object 'request instance' --- diff --git a/application/selector/class_ApplicationHelper.php b/application/selector/class_ApplicationHelper.php index 5c69c52..44d77cb 100644 --- a/application/selector/class_ApplicationHelper.php +++ b/application/selector/class_ApplicationHelper.php @@ -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