From 8c96c0cfa128e4d536788feec87d60719db198fa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 22 Nov 2020 18:51:39 +0100 Subject: [PATCH] Continued: - moved $listInstance + getter/setter from monolithic BaseFrameworkSystem to proper classes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../classes/class_BaseFrameworkSystem.php | 25 ------------------ .../handler/tasks/class_TaskHandler.php | 26 ++++++++++++++++++- .../classes/iterator/class_BaseIterator.php | 25 ++++++++++++++++++ 3 files changed, 50 insertions(+), 26 deletions(-) diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index b6e5924f..26d93920 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -18,7 +18,6 @@ use Org\Mxchange\CoreFramework\Generic\NullPointerException; use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException; use Org\Mxchange\CoreFramework\Handler\Handleable; use Org\Mxchange\CoreFramework\Helper\Helper; -use Org\Mxchange\CoreFramework\Lists\Listable; use Org\Mxchange\CoreFramework\Loader\ClassLoader; use Org\Mxchange\CoreFramework\Localization\ManageableLanguage; use Org\Mxchange\CoreFramework\Manager\ManageableApplication; @@ -109,11 +108,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac */ private $iteratorInstance = NULL; - /** - * Instance of the list - */ - private $listInstance = NULL; - /** * A helper instance for the form */ @@ -630,25 +624,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac return $this->cryptoInstance; } - /** - * Setter for the list instance - * - * @param $listInstance A list of Listable - * @return void - */ - protected final function setListInstance (Listable $listInstance) { - $this->listInstance = $listInstance; - } - - /** - * Getter for the list instance - * - * @return $listInstance A list of Listable - */ - protected final function getListInstance () { - return $this->listInstance; - } - /** * Setter for DatabaseWrapper instance * diff --git a/framework/main/classes/handler/tasks/class_TaskHandler.php b/framework/main/classes/handler/tasks/class_TaskHandler.php index c6b893d3..dfdff9a2 100644 --- a/framework/main/classes/handler/tasks/class_TaskHandler.php +++ b/framework/main/classes/handler/tasks/class_TaskHandler.php @@ -43,6 +43,11 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { */ private $visitorInstance = NULL; + /** + * Instance of the list + */ + private $listInstance = NULL; + /** * Protected constructor * @@ -107,6 +112,25 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { return $this->visitorInstance; } + /** + * Setter for the list instance + * + * @param $listInstance A list of Listable + * @return void + */ + protected final function setListInstance (Listable $listInstance) { + $this->listInstance = $listInstance; + } + + /** + * Getter for the list instance + * + * @return $listInstance A list of Listable + */ + protected final function getListInstance () { + return $this->listInstance; + } + /** * 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 @@ -305,7 +329,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { */ public function hasTasksLeft () { // Do we have tasks there? - $tasksLeft = (($this->getListInstance() instanceof Listable) && ($this->getListInstance()->count() > 0)); + $tasksLeft = ($this->getListInstance()->count() > 0); // Return result return $tasksLeft; diff --git a/framework/main/classes/iterator/class_BaseIterator.php b/framework/main/classes/iterator/class_BaseIterator.php index 092cbc14..c7ea6f09 100644 --- a/framework/main/classes/iterator/class_BaseIterator.php +++ b/framework/main/classes/iterator/class_BaseIterator.php @@ -3,6 +3,7 @@ namespace Org\Mxchange\CoreFramework\Iterator; // Import framework stuff +use Org\Mxchange\CoreFramework\Lists\Listable; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; // Import SPL stuff @@ -31,6 +32,11 @@ use \Iterator; * along with this program. If not, see . */ abstract class BaseIterator extends BaseFrameworkSystem implements Iterator { + /** + * Instance of the list + */ + private $listInstance = NULL; + /** * Protected constructor * @@ -42,4 +48,23 @@ abstract class BaseIterator extends BaseFrameworkSystem implements Iterator { parent::__construct($className); } + /** + * Setter for the list instance + * + * @param $listInstance A list of Listable + * @return void + */ + protected final function setListInstance (Listable $listInstance) { + $this->listInstance = $listInstance; + } + + /** + * Getter for the list instance + * + * @return $listInstance A list of Listable + */ + protected final function getListInstance () { + return $this->listInstance; + } + } -- 2.39.5