]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/commands/class_BaseCommand.php
Continued:
[core.git] / framework / main / classes / commands / class_BaseCommand.php
index 79482c98c05398a710c04a0e00673793d504ed19..49c357b89ac60d23c19af742193bb1edfdf1c738 100644 (file)
@@ -3,13 +3,16 @@
 namespace Org\Mxchange\CoreFramework\Command;
 
 // Import framework stuff
-use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Request\Requestable;
-use Org\Mxchange\CoreFramework\Resolver\Resolver;
 use Org\Mxchange\CoreFramework\Response\Responseable;
-use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
+use Org\Mxchange\CoreFramework\Traits\Resolver\ResolverTrait;
+use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
+
 /**
  * A general (base) command
  *
@@ -33,15 +36,9 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseCommand extends BaseFrameworkSystem {
-       /**
-        * Resolver instance
-        */
-       private $resolverInstance = NULL;
-
-       /**
-        * Template engine instance
-        */
-       private $templateInstance = NULL;
+       // Load traits
+       use CompileableTemplateTrait;
+       use ResolverTrait;
 
        /**
         * Protected constructor
@@ -54,44 +51,6 @@ abstract class BaseCommand extends BaseFrameworkSystem {
                parent::__construct($className);
        }
 
-       /**
-        * Setter for resolver instance
-        *
-        * @param       $resolverInstance       Instance of a command resolver class
-        * @return      void
-        */
-       protected final function setResolverInstance (Resolver $resolverInstance) {
-               $this->resolverInstance = $resolverInstance;
-       }
-
-       /**
-        * Getter for resolver instance
-        *
-        * @return      $resolverInstance       Instance of a command resolver class
-        */
-       protected final function getResolverInstance () {
-               return $this->resolverInstance;
-       }
-
-       /**
-        * Setter for template engine instances
-        *
-        * @param       $templateInstance       An instance of a CompileableTemplate class
-        * @return      void
-        */
-       protected final function setTemplateInstance (CompileableTemplate $templateInstance) {
-               $this->templateInstance = $templateInstance;
-       }
-
-       /**
-        * Getter for template engine instances
-        *
-        * @return      $templateInstance       An instance of a CompileableTemplate class
-        */
-       public final function getTemplateInstance () {
-               return $this->templateInstance;
-       }
-
        /**
         * Initializes the template engine
         *
@@ -119,7 +78,7 @@ abstract class BaseCommand extends BaseFrameworkSystem {
                assert(!$requestInstance->isPostRequestMethod());
 
                // Get the application instance
-               $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+               $applicationInstance = ApplicationHelper::getSelfInstance();
 
                // Transfer application data
                $this->getTemplateInstance()->assignApplicationData();
@@ -154,7 +113,7 @@ abstract class BaseCommand extends BaseFrameworkSystem {
                $this->getTemplateInstance()->loadCodeTemplate($masterTemplate);
 
                // Set title
-               $this->getTemplateInstance()->assignVariable('title', $this->getLanguageInstance()->getMessage('page_' . $applicationInstance->getAppShortName() . '_' . $this->getResolverInstance()->getCommandName() . '_title'));
+               $this->getTemplateInstance()->assignVariable('title', FrameworkBootstrap::getLanguageInstance()->getMessage('page_' . $applicationInstance->getAppShortName() . '_' . $this->getResolverInstance()->getCommandName() . '_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.