]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/class_BaseFrameworkSystem.php
Several MVC classes added, entryPoint method rewritten
[shipsimu.git] / inc / classes / main / class_BaseFrameworkSystem.php
index 796860a240861b315167783a24ceb3f395d7653f..6b4d81694fe6244d3b8f337363da3113f71f55cc 100644 (file)
@@ -4,10 +4,10 @@
  * class handles saving of games etc.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.3.0
+ * @version            0.0.0
  * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.mxchange.org
+ * @link               http://www.ship-simu.org
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -53,6 +53,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        private $dbInstance  = null;
 
+       /**
+        * Instance to an application helper class
+        */
+       private $applicationInstance = null;
+
        /**
         * The real class name
         */
@@ -140,6 +145,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        const EXCEPTION_MISSING_LANGUAGE_HANDLER     = 0x02e;
        const EXCEPTION_MISSING_FILE_IO_HANDLER      = 0x02f;
        const EXCEPTION_MISSING_ELEMENT              = 0x030;
+       const EXCEPTION_INVALID_COMMAND              = 0x031;
+       const EXCEPTION_INVALID_CONTROLLER           = 0x032;
+       const EXCEPTION_HEADERS_ALREADY_SENT         = 0x033;
 
        /**
         * In the super constructor these system classes shall be ignored or else
@@ -150,16 +158,16 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         *--------------------------------------------------------------------*
         */
        private $systemClasses = array(
-               "DebugMiddleware",                      // Debug middleware output sub-system
-               "DebugWebOutput",                       // Debug web output sub-system
-               "DebugConsoleOutput",           // Debug console output sub-system
-               "DebugErrorLogOutput",          // Debug error_log() output sub-system
-               "CompressorChannel",            // Compressor sub-system
+               "DebugMiddleware",                              // Debug middleware output sub-system
+               "DebugWebOutput",                               // Debug web output sub-system
+               "DebugConsoleOutput",                   // Debug console output sub-system
+               "DebugErrorLogOutput",                  // Debug error_log() output sub-system
+               "CompressorChannel",                    // Compressor sub-system
                "FrameworkDirectoryPointer",    // Directory handler sub-system
-               "NullCompressor",                       // Null compressor
-               "Bzip2Compressor",                      // BZIP2 compressor
-               "GzipCompressor",                       // GZIP compressor
-               "WebOutput",                            // Web output sub-system
+               "NullCompressor",                               // Null compressor
+               "Bzip2Compressor",                              // BZIP2 compressor
+               "GzipCompressor",                               // GZIP compressor
+               "WebOutput",                                    // Web output sub-system
        );
 
        /**
@@ -812,11 +820,31 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                $this->fileIOInstance = $fileIOInstance;
        }
 
+       /**
+        * Protected getter for a manageable application helper class
+        *
+        * @return      $applicationInstance    An instance of a manageable application helper class
+        */
+       protected final function getApplicationInstance () {
+               return $this->applicationInstance;
+       }
+
+       /**
+        * Setter for a manageable application helper class
+        *
+        * @param       $applicationInstance    An instance of a manageable application helper class
+        * @return      void
+        */
+       public final function setApplicationInstance (ManageableApplication $applicationInstance) {
+               $this->applicationInstance = $applicationInstance;
+       }
+
        /**
         * Prepare the template engine (TemplateEngine by default) for a given
         * application helper instance (ApplicationHelper by default).
         *
-        * @param               $appInstance                    An application helper instance
+        * @param               $appInstance                    An application helper instance or
+        *                                                                              null if we shall use the default
         * @return              $tplEngine                              The template engine instance
         * @throws              NullPointerException    If the template engine could not
         *                                                                              be initialized
@@ -824,8 +852,22 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         *                                                                              unsupported template engine
         * @throws              MissingLanguageHandlerException If the language sub-system
         *                                                                              is not yet initialized
-        */
-       protected function prepareTemplateEngine (BaseFrameworkSystem $appInstance) {
+        * @throws              NullPointerException    If the discovered application
+        *                                                                              instance is still null
+        */
+       protected function prepareTemplateEngine (BaseFrameworkSystem $appInstance=null) {
+               // Is the application instance set?
+               if (is_null($appInstance)) {
+                       // Get the current instance
+                       $appInstance = $this->getApplicationInstance();
+
+                       // Still null?
+                       if (is_null($appInstance)) {
+                               // Thrown an exception
+                               throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+                       }
+               }
+
                // Generate FQFN for all application templates
                $fqfn = sprintf("%s%s/%s/%s",
                        PATH,