From 7e299c77a502f06e0806e6cbe2292c29b941e4d1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 25 Apr 2012 16:51:22 +0000 Subject: [PATCH] Fix for non-object 'request instance' --- .../selector/class_ApplicationHelper.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) 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 -- 2.30.2