// Set the application instance
$commandInstance->setResolverInstance($resolverInstance);
+ // Load general data like user status and such
+ $commandInstance->prepareCommand();
+
// Return the prepared instance
return $commandInstance;
}
+ /**
+ * Prepares some general data which shall be displayed on every page
+ *
+ * @return void
+ */
+ protected function prepareCommand () {
+ /* @TODO Add some stuff here: Some personal data, app/game related data */
+ }
+
/**
* Executes the given command with given request and response objects
*
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Default action is the one from configuration
+ $actionClass = sprintf("login_%s_action_class", $this->getConfigInstance()->readConfig('login_default_action'));
$action = sprintf("login_%s", $this->getConfigInstance()->readConfig('login_default_action'));
+ // Get "action" from request
+ $actReq = $requestInstance->getRequestElement('action');
+
+ // Do we have a "action" parameter set?
+ if (is_string($actReq)) {
+ // Then use it with prefix
+ $actionClass = sprintf("login_%s_action_class", $actReq);
+ $action = sprintf("login_%s", $actReq);
+ } // END - if
+
+ // Get an action instance
+ $actionInstance = ObjectFactory::createObjectByConfiguredName($actionClass);
+
+ // Execute the action (shall not output anything, see below why)
+ $actionInstance->execute($requestInstance, $responseInstance);
+
// Get the application instance
$appInstance = $this->getResolverInstance()->getApplicationInstance();
// Prepare a template instance
$templateInstance = $this->prepareTemplateEngine($appInstance);
+ // Assign all the application's data with template variables
+ $templateInstance->assignApplicationData($appInstance);
+
// Load the master template
$masterTemplate = $appInstance->getMasterTemplate();
$templateInstance->compileTemplate();
$templateInstance->assignTemplateWithVariable("footer", "footer");
- // Get "action" from request
- $actReq = $requestInstance->getRequestElement("action");
-
- // Do we have a "action" parameter set?
- if (is_string($actReq)) {
- // Then use it with prefix
- $action = sprintf("login_%s", $actReq);
- } // END - if
-
- // @TODO Do the action somewhere here
-
// Load the matching template
$templateInstance->loadCodeTemplate($action);
$templateInstance->loadCodeTemplate($masterTemplate);
// Set title
- $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('login_{$action}_title'));
+ $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage("login_{$action}_title"));
// ... and all variables. This should be merged together in a pattern
// to make things easier. A cache mechanism should be added between