X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=application%2Fselector%2Fclass_ApplicationHelper.php;h=44d77cb62972304e3c9651a7eb0a02e86fa4cdb4;hb=1079ab2b4b8ee62cb5e434b5ee3d04bd7369f954;hp=87f0590f175a4a7ddd6479f02c4163307e9e6a4a;hpb=50d2890511eb23971eb4ee1e392748a42b066def;p=shipsimu.git diff --git a/application/selector/class_ApplicationHelper.php b/application/selector/class_ApplicationHelper.php index 87f0590..44d77cb 100644 --- a/application/selector/class_ApplicationHelper.php +++ b/application/selector/class_ApplicationHelper.php @@ -63,7 +63,7 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication /** * An instance of this class */ - private static $thisInstance = null; + private static $selfInstance = null; /** * Protected constructor @@ -78,16 +78,16 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication /** * Getter for an instance of this class * - * @return $thisInstance An instance of this class + * @return $selfInstance An instance of this class */ - public final static function getInstance () { + public final static function getSelfInstance () { // Is the instance there? - if (is_null(self::$thisInstance)) { - self::$thisInstance = new ApplicationHelper(); - } + if (is_null(self::$selfInstance)) { + self::$selfInstance = new ApplicationHelper(); + } // END - if // Return the instance - return self::$thisInstance; + return self::$selfInstance; } /** @@ -172,12 +172,22 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication * @return void */ public final function entryPoint () { + // 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')) { @@ -190,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 @@ -199,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 @@ -213,6 +222,12 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication // Get a controller instance as well $this->controllerInstance = $resolverInstance->resolveController(); + // Get a web output class + $outputInstance = ObjectFactory::createObjectByConfiguredName('output_class', array($this)); + + // Set it in this application + $this->setWebOutputInstance($outputInstance); + // Handle the request $this->controllerInstance->handleRequest($requestInstance, $responseInstance); }