From: Roland Häder Date: Sat, 7 Nov 2020 17:37:26 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=510a849a26904971bf3f5b58cf7eca73375c6859;p=core.git Continued: - reduced monolithic BaseFrameworkSystem class by moving a lot instances with setter/getter to proper classes Signed-off-by: Roland Häder --- diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index a9385580..4aa523ab 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -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 * diff --git a/framework/main/classes/decorator/xml/class_XmlCompactorDecorator.php b/framework/main/classes/decorator/xml/class_XmlCompactorDecorator.php index b4e39a31..05d45a90 100644 --- a/framework/main/classes/decorator/xml/class_XmlCompactorDecorator.php +++ b/framework/main/classes/decorator/xml/class_XmlCompactorDecorator.php @@ -30,6 +30,11 @@ use Org\Mxchange\CoreFramework\Parser\Parseable; * along with this program. If not, see . */ 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 * diff --git a/framework/main/classes/file_directories/class_BaseAbstractFile.php b/framework/main/classes/file_directories/class_BaseAbstractFile.php index 94559b3b..69b15b06 100644 --- a/framework/main/classes/file_directories/class_BaseAbstractFile.php +++ b/framework/main/classes/file_directories/class_BaseAbstractFile.php @@ -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 * diff --git a/framework/main/classes/handler/tasks/class_TaskHandler.php b/framework/main/classes/handler/tasks/class_TaskHandler.php index 8ef6ffda..c6b893d3 100644 --- a/framework/main/classes/handler/tasks/class_TaskHandler.php +++ b/framework/main/classes/handler/tasks/class_TaskHandler.php @@ -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 diff --git a/framework/main/classes/template/class_BaseTemplateEngine.php b/framework/main/classes/template/class_BaseTemplateEngine.php index 772fa885..e9967765 100644 --- a/framework/main/classes/template/class_BaseTemplateEngine.php +++ b/framework/main/classes/template/class_BaseTemplateEngine.php @@ -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 . */ 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 *