]> git.mxchange.org Git - core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 7 Nov 2020 17:37:26 +0000 (18:37 +0100)
committerRoland Häder <roland@mxchange.org>
Sat, 7 Nov 2020 17:37:26 +0000 (18:37 +0100)
- reduced monolithic BaseFrameworkSystem class by moving a lot instances with
  setter/getter to proper classes

Signed-off-by: Roland Häder <roland@mxchange.org>
framework/main/classes/class_BaseFrameworkSystem.php
framework/main/classes/decorator/xml/class_XmlCompactorDecorator.php
framework/main/classes/file_directories/class_BaseAbstractFile.php
framework/main/classes/handler/tasks/class_TaskHandler.php
framework/main/classes/template/class_BaseTemplateEngine.php

index a9385580a18f2e20fecb6b6c3835471f112ec37d..4aa523abff7f94916c9068994787712aa8c7e8db 100644 (file)
@@ -13,7 +13,6 @@ use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper;
 use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
 use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
-use Org\Mxchange\CoreFramework\Filesystem\FilePointer;
 use Org\Mxchange\CoreFramework\Filesystem\PathWriteProtectedException;
 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
@@ -26,11 +25,9 @@ use Org\Mxchange\CoreFramework\Localization\ManageableLanguage;
 use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
 use Org\Mxchange\CoreFramework\Menu\RenderableMenu;
 use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
-use Org\Mxchange\CoreFramework\Parser\Parseable;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Result\Database\CachedDatabaseResult;
 use Org\Mxchange\CoreFramework\Result\Search\SearchableResult;
-use Org\Mxchange\CoreFramework\Stacker\Stackable;
 use Org\Mxchange\CoreFramework\State\Stateable;
 use Org\Mxchange\CoreFramework\Stream\Input\InputStream;
 use Org\Mxchange\CoreFramework\Stream\Output\OutputStreamer;
@@ -38,7 +35,6 @@ use Org\Mxchange\CoreFramework\Stream\Output\OutputStream;
 use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
 use Org\Mxchange\CoreFramework\User\ManageableAccount;
 use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
-use Org\Mxchange\CoreFramework\Visitor\Visitor;
 
 // Import SPL stuff
 use \stdClass;
@@ -141,16 +137,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
         */
        private $imageInstance = NULL;
 
-       /**
-        * Instance of the stacker
-        */
-       private $stackInstance = NULL;
-
-       /**
-        * A Parseable instance
-        */
-       private $parserInstance = NULL;
-
        /**
         * A helper instance for the form
         */
@@ -171,21 +157,11 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
         */
        private $handlerInstance = NULL;
 
-       /**
-        * Visitor handler instance
-        */
-       private $visitorInstance = NULL;
-
        /**
         * An instance of a database wrapper class
         */
        private $wrapperInstance = NULL;
 
-       /**
-        * An instance of a file I/O pointer class (not handler)
-        */
-       private $pointerInstance = NULL;
-
        /**
         * State instance
         */
@@ -772,44 +748,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
                return $this->imageInstance;
        }
 
-       /**
-        * Setter for stacker instance
-        *
-        * @param       $stackInstance  An instance of an stacker
-        * @return      void
-        */
-       public final function setStackInstance (Stackable $stackInstance) {
-               $this->stackInstance = $stackInstance;
-       }
-
-       /**
-        * Getter for stacker instance
-        *
-        * @return      $stackInstance  An instance of an stacker
-        */
-       public final function getStackInstance () {
-               return $this->stackInstance;
-       }
-
-       /**
-        * Setter for Parseable instance
-        *
-        * @param       $parserInstance An instance of an Parseable
-        * @return      void
-        */
-       public final function setParserInstance (Parseable $parserInstance) {
-               $this->parserInstance = $parserInstance;
-       }
-
-       /**
-        * Getter for Parseable instance
-        *
-        * @return      $parserInstance An instance of an Parseable
-        */
-       public final function getParserInstance () {
-               return $this->parserInstance;
-       }
-
        /**
         * Setter for DatabaseWrapper instance
         *
@@ -905,25 +843,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
                return $this->handlerInstance;
        }
 
-       /**
-        * Setter for visitor instance
-        *
-        * @param       $visitorInstance        A Visitor instance
-        * @return      void
-        */
-       protected final function setVisitorInstance (Visitor $visitorInstance) {
-               $this->visitorInstance = $visitorInstance;
-       }
-
-       /**
-        * Getter for visitor instance
-        *
-        * @return      $visitorInstance        A Visitor instance
-        */
-       protected final function getVisitorInstance () {
-               return $this->visitorInstance;
-       }
-
        /**
         * Setter for Iterator instance
         *
@@ -943,41 +862,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
                return $this->iteratorInstance;
        }
 
-       /**
-        * Setter for FilePointer instance
-        *
-        * @param       $pointerInstance        An instance of an FilePointer class
-        * @return      void
-        */
-       protected final function setPointerInstance (FilePointer $pointerInstance) {
-               $this->pointerInstance = $pointerInstance;
-       }
-
-       /**
-        * Getter for FilePointer instance
-        *
-        * @return      $pointerInstance        An instance of an FilePointer class
-        */
-       public final function getPointerInstance () {
-               return $this->pointerInstance;
-       }
-
-       /**
-        * Unsets pointer instance which triggers a call of __destruct() if the
-        * instance is still there. This is surely not fatal on already "closed"
-        * file pointer instances.
-        *
-        * I don't want to mess around with above setter by giving it a default
-        * value NULL as setter should always explicitly only set (existing) object
-        * instances and NULL is NULL.
-        *
-        * @return      void
-        */
-       protected final function unsetPointerInstance () {
-               // Simply it to NULL
-               $this->pointerInstance = NULL;
-       }
-
        /**
         * Setter for state instance
         *
index b4e39a315b10ca0b8c79f894cb484475a2e1dcc0..05d45a90724ad40a5fa8f3824708899beaf100d2 100644 (file)
@@ -30,6 +30,11 @@ use Org\Mxchange\CoreFramework\Parser\Parseable;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class XmlCompactorDecorator extends BaseDecorator implements Parseable {
+       /**
+        * Instance of the stacker
+        */
+       private $stackInstance = NULL;
+
        /**
         * Protected constructor
         *
@@ -63,6 +68,25 @@ class XmlCompactorDecorator extends BaseDecorator implements Parseable {
                return $parserInstance;
        }
 
+       /**
+        * Setter for Parseable instance
+        *
+        * @param       $parserInstance An instance of an Parseable
+        * @return      void
+        */
+       protected final function setParserInstance (Parseable $parserInstance) {
+               $this->parserInstance = $parserInstance;
+       }
+
+       /**
+        * Getter for Parseable instance
+        *
+        * @return      $parserInstance An instance of an Parseable
+        */
+       private final function getParserInstance () {
+               return $this->parserInstance;
+       }
+
        /**
         * Parses the given XML content
         *
index 94559b3b3a39788230262fe820e33a7933ff73aa..69b15b06e72c62750a7cef99579a1ed09b66a95b 100644 (file)
@@ -36,6 +36,11 @@ abstract class BaseAbstractFile extends BaseFrameworkSystem implements FilePoint
         */
        private $totalEntries = 0;
 
+       /**
+        * An instance of a file I/O pointer class (not handler)
+        */
+       private $pointerInstance = NULL;
+
        /**
         * Protected constructor
         *
@@ -47,6 +52,41 @@ abstract class BaseAbstractFile extends BaseFrameworkSystem implements FilePoint
                parent::__construct($className);
        }
 
+       /**
+        * Setter for FilePointer instance
+        *
+        * @param       $pointerInstance        An instance of an FilePointer class
+        * @return      void
+        */
+       protected final function setPointerInstance (FilePointer $pointerInstance) {
+               $this->pointerInstance = $pointerInstance;
+       }
+
+       /**
+        * Getter for FilePointer instance
+        *
+        * @return      $pointerInstance        An instance of an FilePointer class
+        */
+       public final function getPointerInstance () {
+               return $this->pointerInstance;
+       }
+
+       /**
+        * Unsets pointer instance which triggers a call of __destruct() if the
+        * instance is still there. This is surely not fatal on already "closed"
+        * file pointer instances.
+        *
+        * I don't want to mess around with above setter by giving it a default
+        * value NULL as setter should always explicitly only set (existing) object
+        * instances and NULL is NULL.
+        *
+        * @return      void
+        */
+       protected final function unsetPointerInstance () {
+               // Simply it to NULL
+               $this->pointerInstance = NULL;
+       }
+
        /**
         * Destructor for cleaning purposes, etc
         *
index 8ef6ffda24aeff1ba076333e2ec698ea7879aabe..c6b893d3670fecd142f256b19f46d6912be41066 100644 (file)
@@ -10,6 +10,7 @@ use Org\Mxchange\CoreFramework\Lists\Listable;
 use Org\Mxchange\CoreFramework\Registry\Registerable;
 use Org\Mxchange\CoreFramework\Task\Taskable;
 use Org\Mxchange\CoreFramework\Visitor\Visitable;
+use Org\Mxchange\CoreFramework\Visitor\Visitor;
 
 /**
  * A Task handler
@@ -37,6 +38,11 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
        // Exception constants
        const EXCEPTION_TASK_IS_INVALID = 0xb00;
 
+       /**
+        * Visitor handler instance
+        */
+       private $visitorInstance = NULL;
+
        /**
         * Protected constructor
         *
@@ -82,6 +88,25 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
                return $handlerInstance;
        }
 
+       /**
+        * Setter for visitor instance
+        *
+        * @param       $visitorInstance        An instance of a Visitor class
+        * @return      void
+        */
+       protected final function setVisitorInstance (Visitor $visitorInstance) {
+               $this->visitorInstance = $visitorInstance;
+       }
+
+       /**
+        * Getter for visitor instance
+        *
+        * @return      $visitorInstance        An instance of a Visitor class
+        */
+       protected final function getVisitorInstance () {
+               return $this->visitorInstance;
+       }
+
        /**
         * Tries to execute the given task. If as task should not be started (yet)
         * or the interval time (see task_interval_delay) is not yet reached the
index 772fa885b04850eb8aa299aefab156179e29f998..e996776554520fee0107fd5a017d676dd4113991 100644 (file)
@@ -13,6 +13,7 @@ use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Response\Responseable;
+use Org\Mxchange\CoreFramework\Stacker\Stackable;
 use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
 
 // Import SPL stuff
@@ -42,6 +43,12 @@ use \SplFileInfo;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseTemplateEngine extends BaseFrameworkSystem {
+       // Exception codes for the template engine
+       const EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED   = 0x110;
+       const EXCEPTION_TEMPLATE_CONTAINS_INVALID_VAR = 0x111;
+       const EXCEPTION_INVALID_VIEW_HELPER           = 0x112;
+       const EXCEPTION_VARIABLE_IS_MISSING           = 0x113;
+
        /**
         * The file I/O instance for the template loader
         */
@@ -171,11 +178,10 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem {
         */
        private $xmlCompacting = false;
 
-       // Exception codes for the template engine
-       const EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED   = 0x110;
-       const EXCEPTION_TEMPLATE_CONTAINS_INVALID_VAR = 0x111;
-       const EXCEPTION_INVALID_VIEW_HELPER           = 0x112;
-       const EXCEPTION_VARIABLE_IS_MISSING           = 0x113;
+       /**
+        * Instance of the stacker
+        */
+       private $stackInstance = NULL;
 
        /**
         * Protected constructor
@@ -1634,6 +1640,25 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem {
                $this->fileIoInstance = $fileIoInstance;
        }
 
+       /**
+        * Setter for stacker instance
+        *
+        * @param       $stackInstance  An instance of an stacker
+        * @return      void
+        */
+       protected final function setStackInstance (Stackable $stackInstance) {
+               $this->stackInstance = $stackInstance;
+       }
+
+       /**
+        * Getter for stacker instance
+        *
+        * @return      $stackInstance  An instance of an stacker
+        */
+       public final function getStackInstance () {
+               return $this->stackInstance;
+       }
+
        /**
         * Removes all commentd, tabs and new-line characters to compact the content
         *