]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/commands/html/class_HtmlLoginAreaCommand.php
Continued:
[core.git] / framework / main / classes / commands / html / class_HtmlLoginAreaCommand.php
index f0035813eab0756ce5b95e4e1ae3381c3cecb090..0c59b7ef3122ca5e1a89fbd47fce9122925b1949 100644 (file)
@@ -4,22 +4,24 @@ namespace Org\Mxchange\CoreFramework\Command\Login;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Action\PerformableAction;
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Command\BaseCommand;
 use Org\Mxchange\CoreFramework\Command\Commandable;
 use Org\Mxchange\CoreFramework\Controller\Controller;
-use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
 use Org\Mxchange\CoreFramework\Request\Requestable;
 use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
 use Org\Mxchange\CoreFramework\Response\Responseable;
-use Org\Mxchange\CoreFramework\String\Utils\StringUtils;
+use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
 
 /**
  * A command for the login area (member/gamer area)
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -47,7 +49,7 @@ class HtmlLoginAreaCommand extends BaseCommand implements Commandable {
         *
         * @return      void
         */
-       protected function __construct () {
+       private function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
        }
@@ -90,82 +92,79 @@ class HtmlLoginAreaCommand extends BaseCommand implements Commandable {
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get the action instance from registry
-               $actionInstance = GenericRegistry::getRegistry()->getInstance('action');
+               $actionInstance = ObjectRegistry::getRegistry('generic')->getInstance('action');
 
                // Do we have an action here?
                if ($actionInstance instanceof PerformableAction) {
                        // Execute the action (shall not output anything, see below why)
                        $actionInstance->execute($requestInstance, $responseInstance);
-               } // END - if
+               }
 
                // Get the application instance
-               $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
-
-               // Prepare a template instance
-               $templateInstance = $this->prepareTemplateInstance($applicationInstance);
+               $applicationInstance = ApplicationHelper::getSelfInstance();
 
                // Assign base URL
-               $templateInstance->assignConfigVariable('base_url');
+               $this->getTemplateInstance()->assignConfigVariable('base_url');
 
                // Assign all the application's data with template variables
-               $templateInstance->assignApplicationData();
+               $this->getTemplateInstance()->assignApplicationData();
 
                // Load the master template
                $masterTemplate = $applicationInstance->buildMasterTemplateName();
 
                // Load header template
-               $templateInstance->loadCodeTemplate('header');
+               $this->getTemplateInstance()->loadCodeTemplate('header');
 
                // Compile and assign it with a variable
-               $templateInstance->compileTemplate();
-               $templateInstance->assignTemplateWithVariable('header', 'header');
+               $this->getTemplateInstance()->compileTemplate();
+               $this->getTemplateInstance()->assignTemplateWithVariable('header', 'header');
 
                // Load footer template
-               $templateInstance->loadCodeTemplate('footer');
+               $this->getTemplateInstance()->loadCodeTemplate('footer');
 
                // Compile and assign it with a variable
-               $templateInstance->compileTemplate();
-               $templateInstance->assignTemplateWithVariable('footer', 'footer');
+               $this->getTemplateInstance()->compileTemplate();
+               $this->getTemplateInstance()->assignTemplateWithVariable('footer', 'footer');
 
                // Load the matching template
-               $templateInstance->loadCodeTemplate('action_' . $this->actionName);
+               $this->getTemplateInstance()->loadCodeTemplate('action_' . $this->actionName);
 
                // Assign the template with the master template as a content ... ;)
-               $templateInstance->compileTemplate();
-               $templateInstance->assignTemplateWithVariable('action_' . $this->actionName, 'login_content');
+               $this->getTemplateInstance()->compileTemplate();
+               $this->getTemplateInstance()->assignTemplateWithVariable('action_' . $this->actionName, 'login_content');
 
                // Load main template
-               $templateInstance->loadCodeTemplate('login_main');
+               $this->getTemplateInstance()->loadCodeTemplate('login_main');
 
                // Assign the main template with the master template as a content ... ;)
-               $templateInstance->compileTemplate();
-               $templateInstance->assignTemplateWithVariable('login_main', 'main_content');
+               $this->getTemplateInstance()->compileTemplate();
+               $this->getTemplateInstance()->assignTemplateWithVariable('login_main', 'main_content');
 
                // Load the master template
-               $templateInstance->loadCodeTemplate($masterTemplate);
+               $this->getTemplateInstance()->loadCodeTemplate($masterTemplate);
 
                // Set title
-               $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage($this->actionName . '_title'));
+               $this->getTemplateInstance()->assignVariable('title', FrameworkBootstrap::getLanguageInstance()->getMessage($this->actionName . '_title'));
 
                // Construct the menu in every command. We could do this in BaseCommand class. But this means
                // *every* command has a navigation system and that is want we don't want.
-               $menuInstance = ObjectFactory::createObjectByConfiguredName('login_area_menu_class', array($applicationInstance));
+               $menuInstance = ObjectFactory::createObjectByConfiguredName('login_area_menu_class');
 
                // Render the menu
                $menuInstance->renderMenu();
 
                // Transfer it to the template engine instance
-               $menuInstance->transferContentToTemplateEngine($templateInstance);
+               $menuInstance->transferContentToTemplateEngine($this->getTemplateInstance());
 
                /*
                 * ... and all variables. This should be merged together in a pattern
                 * to make things easier. A cache mechanism should be added between
                 * these two calls to cache compiled templates.
                 */
-               $templateInstance->compileVariables();
+               $this->getTemplateInstance()->compileVariables();
 
                // Get the content back from the template engine and put it in response class
-               $templateInstance->transferToResponse($responseInstance);
+               $this->getTemplateInstance()->transferToResponse($responseInstance);
        }
 
        /**
@@ -176,26 +175,20 @@ class HtmlLoginAreaCommand extends BaseCommand implements Commandable {
         * @return      void
         */
        public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
-               // Default is no action
-               $actionInstance = NULL;
-
-               // Get registry
-               $registryInstance = GenericRegistry::getRegistry();
-
                // Get our application instance from the registry
-               $applicationInstance = $registryInstance->getInstance('application');
+               $applicationInstance = ApplicationHelper::getSelfInstance();
 
                // Default action is the one from configuration
-               $this->actionName = StringUtils::convertDashesToUnderscores($applicationInstance->getAppShortName()) . '_login_' . $this->getConfigInstance()->getConfigEntry('login_default_action');
+               $this->actionName = StringUtils::convertDashesToUnderscores($applicationInstance->getAppShortName()) . '_login_' . FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('login_default_action');
 
                // Get "action" from request
                $actReq = $requestInstance->getRequestElement('action');
 
                // Do we have a "action" parameter set?
-               if ((is_string($actReq)) && (!empty($actReq))) {
+               if (!empty($actReq)) {
                        // Then use it with prefix
                        $this->actionName = StringUtils::convertDashesToUnderscores($applicationInstance->getAppShortName()) . '_login_' . $actReq;
-               } // END - if
+               }
 
                // Get a resolver
                $actionResolver = HtmlActionResolver::createHtmlActionResolver($this->actionName);
@@ -207,7 +200,7 @@ class HtmlLoginAreaCommand extends BaseCommand implements Commandable {
                $actionInstance->addExtraFilters($controllerInstance, $requestInstance);
 
                // Remember this action in registry
-               GenericRegistry::getRegistry()->addInstance('action', $actionInstance);
+               ObjectRegistry::getRegistry('generic')->addInstance('action', $actionInstance);
        }
 
 }